Restructuring
This commit is contained in:
+1
-1
@@ -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[];
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
CREATE TABLE IF NOT EXISTS product_records (
|
||||
webflowProductId INTEGER NOT NULL,
|
||||
printfulProductId INTEGER NOT NULL,
|
||||
UNIQUE(webflowProductId, printfulProductId)
|
||||
)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { productRecords } from "./data/product-records";
|
||||
import { productRecords } from "./product-records";
|
||||
import { Printful } from "./printful"
|
||||
|
||||
export namespace Webflow {
|
||||
|
||||
@@ -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();
|
||||
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user