reviewing and updating deck generation
This commit is contained in:
parent
521ffe3b6e
commit
9d1a82bdf0
5 changed files with 10 additions and 51 deletions
|
|
@ -29,7 +29,7 @@ Done when: `GET /api/decks/1/terms?limit=10` returns 10 terms from a specific de
|
||||||
[x] Write Drizzle schema: `terms`, `translations`, `language_pairs`, `term_glosses`, `decks`, `deck_terms`
|
[x] Write Drizzle schema: `terms`, `translations`, `language_pairs`, `term_glosses`, `decks`, `deck_terms`
|
||||||
[x] Write and run migration (includes CHECK constraints for `pos`, `gloss_type`)
|
[x] Write and run migration (includes CHECK constraints for `pos`, `gloss_type`)
|
||||||
[x] Write `packages/db/src/seed.ts` (imports ALL terms + translations, NO decks)
|
[x] Write `packages/db/src/seed.ts` (imports ALL terms + translations, NO decks)
|
||||||
[ ] Download CEFR A1/A2 noun lists (from GitHub repos)
|
[x] Download CEFR A1/A2 noun lists (from GitHub repos)
|
||||||
[ ] Write `scripts/build_decks.ts` (reads external CEFR lists, matches to DB, creates decks)
|
[ ] Write `scripts/build_decks.ts` (reads external CEFR lists, matches to DB, creates decks)
|
||||||
[ ] Run `pnpm db:seed` → populates terms
|
[ ] Run `pnpm db:seed` → populates terms
|
||||||
[ ] Run `pnpm db:build-decks` → creates curated decks
|
[ ] Run `pnpm db:build-decks` → creates curated decks
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
a
|
|
||||||
other
|
|
||||||
us
|
|
||||||
may
|
|
||||||
st
|
|
||||||
paul
|
|
||||||
new
|
|
||||||
software
|
|
||||||
oxford
|
|
||||||
english
|
|
||||||
mary
|
|
||||||
japan
|
|
||||||
while
|
|
||||||
pp
|
|
||||||
membership
|
|
||||||
manchester
|
|
||||||
tony
|
|
||||||
alan
|
|
||||||
jones
|
|
||||||
un
|
|
||||||
northern
|
|
||||||
simon
|
|
||||||
behalf
|
|
||||||
co
|
|
||||||
graham
|
|
||||||
joe
|
|
||||||
guy
|
|
||||||
lewis
|
|
||||||
jane
|
|
||||||
taylor
|
|
||||||
co-operation
|
|
||||||
travel
|
|
||||||
self
|
|
||||||
thatcher
|
|
||||||
|
|
@ -7,7 +7,6 @@ import {
|
||||||
unique,
|
unique,
|
||||||
check,
|
check,
|
||||||
boolean,
|
boolean,
|
||||||
integer,
|
|
||||||
primaryKey,
|
primaryKey,
|
||||||
index,
|
index,
|
||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
|
|
@ -133,19 +132,19 @@ export const decks = pgTable(
|
||||||
id: uuid().primaryKey().defaultRandom(),
|
id: uuid().primaryKey().defaultRandom(),
|
||||||
name: text().notNull(),
|
name: text().notNull(),
|
||||||
description: text(),
|
description: text(),
|
||||||
language_pair_id: uuid()
|
validated_for_languages: varchar({ length: 10 })
|
||||||
|
.array()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => language_pairs.id, { onDelete: "cascade" }),
|
.default([]),
|
||||||
created_by: uuid()
|
|
||||||
.notNull()
|
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
|
||||||
is_public: boolean().default(false).notNull(),
|
is_public: boolean().default(false).notNull(),
|
||||||
created_at: timestamp({ withTimezone: true }).defaultNow().notNull(),
|
created_at: timestamp({ withTimezone: true }).defaultNow().notNull(),
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
unique("unique_deck_name").on(table.name, table.created_by),
|
check(
|
||||||
index("idx_decks_created_by").on(table.created_by),
|
"validated_languages_check",
|
||||||
index("idx_decks_language_pair").on(table.language_pair_id),
|
sql`validated_for_languages <@ ARRAY[${sql.raw(SUPPORTED_LANGUAGE_CODES.map((l) => `'${l}'`).join(", "))}]::varchar[]`,
|
||||||
|
),
|
||||||
|
unique("unique_deck_name").on(table.name),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -158,7 +157,6 @@ export const deck_terms = pgTable(
|
||||||
term_id: uuid()
|
term_id: uuid()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => terms.id, { onDelete: "cascade" }),
|
.references(() => terms.id, { onDelete: "cascade" }),
|
||||||
position: integer().notNull(),
|
|
||||||
added_at: timestamp({ withTimezone: true }).defaultNow().notNull(),
|
added_at: timestamp({ withTimezone: true }).defaultNow().notNull(),
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Close the DB connection
|
||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import { db } from "@glossa/db";
|
import { db } from "@glossa/db";
|
||||||
import { translations } from "@glossa/db/schema";
|
import { translations } from "@glossa/db/schema";
|
||||||
import { inArray, and, eq } from "drizzle-orm";
|
import { inArray } from "drizzle-orm";
|
||||||
|
|
||||||
const wordlistPath = "./src/data/wordlists/top1000englishnouns";
|
const wordlistPath = "./src/data/wordlists/top1000englishnouns";
|
||||||
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import { db } from "./index.js";
|
|
||||||
|
|
||||||
const result = await db.execute("select 1");
|
|
||||||
|
|
||||||
console.log("result: ", result);
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue