@@ -7,7 +7,12 @@ console.log("connected to sqlite");
7
7
8
8
console . log ( 'creating "stats" table' ) ;
9
9
const query = sqlite . query (
10
- "CREATE TABLE `stats` (`id` text, `bundle_name` text UNIQUE, `json_stats` text);" ,
10
+ `CREATE TABLE "stats" (
11
+ "id" text,
12
+ "bundle_name" text,
13
+ "json_stats" text,
14
+ PRIMARY KEY ("id", "bundle_name")
15
+ );` ,
11
16
) ;
12
17
query . run ( ) ;
13
18
console . log ( 'created "stats" table' ) ;
@@ -55,7 +60,7 @@ app.all("/file-upload/:id/:status{[0-9]{3}}", async (c) => {
55
60
const data : { bundleName : string } = await c . req . json ( ) ;
56
61
console . log ( "finished upload" ) ;
57
62
58
- console . log ( "inserting stats" ) ;
63
+ console . log ( "inserting stats for" , data . bundleName ) ;
59
64
const bundleName = data ! . bundleName ;
60
65
const insertStats = JSON . stringify ( data ) ;
61
66
const query = sqlite . query (
@@ -88,14 +93,15 @@ app.all("/get-stats/:id", (c) => {
88
93
return c . text ( "Not found" , { status : 404 } ) ;
89
94
} ) ;
90
95
91
- app . all ( "/get-stats-by-bundle-name/:bundleName" , ( c ) => {
96
+ app . all ( "/get-stats-by-bundle-name/:id/:bundleName" , ( c ) => {
97
+ const id = c . req . param ( "id" ) ;
92
98
const bundleName = c . req . param ( "bundleName" ) ;
93
99
console . log ( "getting stats" , bundleName ) ;
94
100
95
101
const query = sqlite . query (
96
- "SELECT * FROM stats WHERE bundle_name = $bundleName" ,
102
+ "SELECT * FROM stats WHERE bundle_name = $bundleName AND id = $id " ,
97
103
) ;
98
- const result = query . get ( { $bundleName : bundleName } ) as {
104
+ const result = query . get ( { $bundleName : bundleName , $id : id } ) as {
99
105
id : string ;
100
106
json_stats : string ;
101
107
} ;
0 commit comments