diff --git a/calculator/calc.ts b/calculator/calc.ts index 0479678..e80aea8 100644 --- a/calculator/calc.ts +++ b/calculator/calc.ts @@ -1,5 +1,5 @@ import { activities, Activity, Attribute, attributes, BenchmarkPerformance, findNearestPoints, Gender, getActivityAttribute, kgToLb, Levels, msToTime, StandardsItem } from "./util"; -import rawStandards from "./data/standards.json" assert { type: "json" } +import rawStandards from "./standards.json" assert { type: "json" } const standards = rawStandards as StandardsItem[]; diff --git a/calculator/data/standards.json b/calculator/standards.json similarity index 100% rename from calculator/data/standards.json rename to calculator/standards.json diff --git a/commerce/data/data.db b/commerce/data/data.db deleted file mode 100644 index 9073ddb..0000000 Binary files a/commerce/data/data.db and /dev/null differ diff --git a/commerce/data/seed.sql b/commerce/data/seed.sql deleted file mode 100644 index f01665a..0000000 --- a/commerce/data/seed.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS product_records ( - webflowProductId INTEGER NOT NULL, - printfulProductId INTEGER NOT NULL, - UNIQUE(webflowProductId, printfulProductId) -) diff --git a/commerce/data/product-records.ts b/commerce/product-records.ts similarity index 100% rename from commerce/data/product-records.ts rename to commerce/product-records.ts diff --git a/commerce/webflow.ts b/commerce/webflow.ts index e3f0dbd..c891132 100644 --- a/commerce/webflow.ts +++ b/commerce/webflow.ts @@ -1,4 +1,4 @@ -import { productRecords } from "./data/product-records"; +import { productRecords } from "./product-records"; import { Printful } from "./printful" export namespace Webflow { diff --git a/data/product-records.ts b/data/product-records.ts deleted file mode 100644 index 46d826b..0000000 --- a/data/product-records.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Database } from "bun:sqlite"; - -interface ProductRecord { - webflowProductId: number; - printfulProductId: number; -} - -class ProductRecords { - private db: Database; - - constructor() { - const dbPath = Bun.env.NODE_ENV === "production" ? - "/data/data.db" : - "./data/data.db"; - - this.db = new Database(dbPath); - } - - findFromWebflow(webflowProductId: number): ProductRecord | undefined { - const row = this.db.query(` - SELECT * FROM product_records WHERE webflowProductId = ? - `).get(webflowProductId); - - return row as ProductRecord | undefined; - } - - findFromPrintful(printfulProductId: number): ProductRecord | undefined { - const row = this.db.query(` - SELECT * FROM product_records WHERE printfulProductId = ? - `).get(printfulProductId); - - return row as ProductRecord | undefined; - } - - deleteFromWebflow(webflowProductId: number) { - this.db.run(` - DELETE FROM product_records WHERE webflowProductId = ? - `, [webflowProductId]); - } - - deleteFromPrintful(printfulProductId: number) { - this.db.run(` - DELETE FROM product_records WHERE printfulProductId = ? - `, [printfulProductId]); - } - - add(record: ProductRecord): void { - this.db.run(` - INSERT OR IGNORE INTO product_records (webflowProductId, printfulProductId) - VALUES (?, ?) - `, [record.webflowProductId, record.printfulProductId]); - } - - all(): ProductRecord[] { - return this.db.query(`SELECT * FROM product_records`).all() as ProductRecord[]; - } -} - -export const productRecords = new ProductRecords(); diff --git a/main.ts b/main.ts index 872d378..f670b2d 100644 --- a/main.ts +++ b/main.ts @@ -1,6 +1,6 @@ import { calcAttributeLevels, calcPlayerLevel, computeLevels } from "./calculator/calc.ts"; import { Activity, BenchmarkPerformance, Gender } from "./calculator/util.ts"; -import { productRecords } from "./commerce/data/product-records.ts"; +import { productRecords } from "./commerce/product-records.ts"; import { Printful } from "./commerce/printful.ts" import { Webflow } from "./commerce/webflow.ts";