From e0175de85f63610bba9c82fcd1be09ab556a534d Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Sat, 29 Mar 2025 20:47:18 -0500 Subject: [PATCH 1/4] created README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..1554f8f --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Vegan Barcode + +The goal of this project is to be a crowd sourced resource to find out if a product is vegan + + +## Task list +- figure out how we want to handle database migrations +- create mobile and desktop front ends +- create search api +- create upload api +- moderation tooling? +- create workers + - barnivore lookup + - alergen ingredient database lookup? \ No newline at end of file From b82e7920298f5eb650cd8e4952aa26241833d9a9 Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Sat, 29 Mar 2025 20:48:40 -0500 Subject: [PATCH 2/4] removed un needed custom id's from table definitions --- src/database/database.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/database/database.go b/src/database/database.go index 2c2a14a..c9175c7 100644 --- a/src/database/database.go +++ b/src/database/database.go @@ -10,7 +10,7 @@ import ( "github.com/vingarcia/ksql/adapters/kpgx" ) -var ProductsTable = ksql.NewTable("products", "product_id") +var ProductsTable = ksql.NewTable("products") type Product struct { id int `ksql:"id"` @@ -19,7 +19,7 @@ type Product struct { created_at time.Time `ksql:"created_at,timeNowUTC"` } -var UserClaimsTable = ksql.NewTable("user_claims", "user_claim_id") +var UserClaimsTable = ksql.NewTable("user_claims") type UserClaim struct { id int `ksql:"id"` @@ -39,7 +39,7 @@ const ( IngredientsList ) -var AutomatedClaimsTable = ksql.NewTable("automated_claims", "automated_claim_id") +var AutomatedClaimsTable = ksql.NewTable("automated_claims") type AutomatedClaim struct { id int `ksql:"id"` From 8543aab3664961668c634eacf29174c46fe8986a Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Sat, 29 Mar 2025 20:57:08 -0500 Subject: [PATCH 3/4] added tasks to README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1554f8f..85b3fb2 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,12 @@ The goal of this project is to be a crowd sourced resource to find out if a prod ## Task list - figure out how we want to handle database migrations -- create mobile and desktop front ends +- database object models should be separated out from database migration function +- create main process that runs database migration and then starts api - create search api - create upload api -- moderation tooling? - create workers - barnivore lookup - - alergen ingredient database lookup? \ No newline at end of file + - alergen ingredient database lookup? +- create mobile and desktop front ends +- moderation tooling? \ No newline at end of file From 5ae0a5856e0288cdd88d6897cfe407ced4c89b96 Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Tue, 8 Apr 2025 18:36:11 -0500 Subject: [PATCH 4/4] added query draft --- query_draft.sql | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 query_draft.sql diff --git a/query_draft.sql b/query_draft.sql new file mode 100644 index 0000000..19a6283 --- /dev/null +++ b/query_draft.sql @@ -0,0 +1,39 @@ +SELECT + cluster, + id, + worker, + evidence_type, + evidence, + category, + polarity, + created_at, + created_by +FROM ( + SELECT + cluster, + id, + worker, + evidence_type, + evidence, + category, + polarity, + created_at, + created_by, + ROW_NUMBER() OVER (PARTITION BY category ORDER BY created_at DESC) AS rn + FROM ( + ( + SELECT "user" as cluster, id, product_id, null as worker, evidence_type, evidence, unnest(claim) as category, true as polarity, created_at, created_by FROM user_claims + UNION ALL + SELECT "automated" as cluster, id, product_id, worker, null as evidence_type, evidence, unnest(claim) as category, true as polarity, created_at, null as created_by FROM automated_claims + ) + UNION ALL + ( + SELECT "user" as cluster, id, product_id, null as worker, evidence_type, evidence, unnest(counter_claim) as category, false as polarity, created_at, created_by FROM user_claims + UNION ALL + SELECT "automated" as cluster, id, product_id, worker, null as evidence_type, evidence, unnest(counter_claim) as category, false as polarity, created_at, null as created_by FROM automated_claims + ) + ) + WHERE product_id = ??? +) +WHERE rn = 1 +ORDER BY created_at;