refactoring

This commit is contained in:
lila 2026-04-02 15:48:31 +02:00
parent cdedbc44cd
commit 38a62ca3a4

View file

@ -1,7 +1,7 @@
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import { db } from "@glossa/db"; import { db } from "@glossa/db";
import { translations, terms, decks, deck_terms } from "@glossa/db/schema"; import { translations, terms, decks, deck_terms } from "@glossa/db/schema";
import { inArray, and, eq, count, ne } from "drizzle-orm"; import { inArray, and, eq, ne, countDistinct } from "drizzle-orm";
type DbOrTx = Parameters<Parameters<typeof db.transaction>[0]>[0]; type DbOrTx = Parameters<Parameters<typeof db.transaction>[0]>[0];
@ -64,7 +64,7 @@ const validateLanguages = async (sourceLanguage: string, termIds: string[]) => {
const coverage = await db const coverage = await db
.select({ .select({
language: translations.language_code, language: translations.language_code,
coveredCount: count(translations.term_id), coveredCount: countDistinct(translations.term_id),
}) })
.from(translations) .from(translations)
.where( .where(