@@ -7,7 +7,12 @@ console.log("connected to sqlite");
77
88console . log ( 'creating "stats" table' ) ;
99const 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+ );` ,
1116) ;
1217query . run ( ) ;
1318console . log ( 'created "stats" table' ) ;
@@ -55,7 +60,7 @@ app.all("/file-upload/:id/:status{[0-9]{3}}", async (c) => {
5560 const data : { bundleName : string } = await c . req . json ( ) ;
5661 console . log ( "finished upload" ) ;
5762
58- console . log ( "inserting stats" ) ;
63+ console . log ( "inserting stats for" , data . bundleName ) ;
5964 const bundleName = data ! . bundleName ;
6065 const insertStats = JSON . stringify ( data ) ;
6166 const query = sqlite . query (
@@ -88,14 +93,15 @@ app.all("/get-stats/:id", (c) => {
8893 return c . text ( "Not found" , { status : 404 } ) ;
8994} ) ;
9095
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" ) ;
9298 const bundleName = c . req . param ( "bundleName" ) ;
9399 console . log ( "getting stats" , bundleName ) ;
94100
95101 const query = sqlite . query (
96- "SELECT * FROM stats WHERE bundle_name = $bundleName" ,
102+ "SELECT * FROM stats WHERE bundle_name = $bundleName AND id = $id " ,
97103 ) ;
98- const result = query . get ( { $bundleName : bundleName } ) as {
104+ const result = query . get ( { $bundleName : bundleName , $id : id } ) as {
99105 id : string ;
100106 json_stats : string ;
101107 } ;
0 commit comments