mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-08-03 11:07:00 -04:00
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import './setup.ts';
|
|
|
|
import SQL from 'sql-template-strings';
|
|
|
|
import dbConnection from './db.ts';
|
|
|
|
(async () => {
|
|
const db = await dbConnection();
|
|
const terms: Record<string, Record<string, Record<string, string>>> = {};
|
|
for (const term of await db.all(SQL`
|
|
SELECT id, key, locale, flags, images FROM terms WHERE approved = 1 AND deleted = 0 AND key IS NOT NULL
|
|
`)) {
|
|
if (terms[term.locale] === undefined) {
|
|
terms[term.locale] = {};
|
|
}
|
|
terms[term.locale][term.key] = term;
|
|
}
|
|
for (const locale in terms) {
|
|
if (!Object.hasOwn(terms, locale)) {
|
|
continue;
|
|
}
|
|
if (locale === 'pl') {
|
|
continue;
|
|
}
|
|
for (const key in terms[locale]) {
|
|
if (!Object.hasOwn(terms[locale], key)) {
|
|
continue;
|
|
}
|
|
const term = terms[locale][key];
|
|
if (terms.pl[term.key] === undefined) {
|
|
continue;
|
|
}
|
|
const sql = SQL`
|
|
UPDATE terms
|
|
SET flags = '${terms.pl[term.key].flags}', images = '${terms.pl[term.key].images}'
|
|
WHERE id = '${term.id}';`;
|
|
console.log(sql);
|
|
await db.get(sql);
|
|
}
|
|
}
|
|
})();
|