This commit is contained in:
C4illin
2024-05-26 12:44:28 +02:00
parent a41e5d8c99
commit 50e9b861b0
2 changed files with 19 additions and 15 deletions

View File

@@ -10,4 +10,4 @@ const config = {
plugins: ["@ianvs/prettier-plugin-sort-imports"], plugins: ["@ianvs/prettier-plugin-sort-imports"],
}; };
export default config; export default config;

View File

@@ -32,8 +32,9 @@ const ACCOUNT_REGISTRATION =
// convertedFiles : 0, // convertedFiles : 0,
// outputFiles: [], // outputFiles: [],
// init db // init db if not exists
db.exec(` if (!db.query("SELECT * FROM sqlite_master WHERE type='table'").get()) {
db.exec(`
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
email TEXT NOT NULL, email TEXT NOT NULL,
@@ -54,7 +55,9 @@ CREATE TABLE IF NOT EXISTS jobs (
status TEXT DEFAULT 'not started', status TEXT DEFAULT 'not started',
num_files INTEGER DEFAULT 0, num_files INTEGER DEFAULT 0,
FOREIGN KEY (user_id) REFERENCES users(id) FOREIGN KEY (user_id) REFERENCES users(id)
);`); );
PRAGMA user_version = 1;`);
}
const dbVersion = ( const dbVersion = (
db.query("PRAGMA user_version").get() as { user_version?: number } db.query("PRAGMA user_version").get() as { user_version?: number }
@@ -64,6 +67,7 @@ if (dbVersion === 0) {
"ALTER TABLE file_names ADD COLUMN status TEXT DEFAULT 'not started';", "ALTER TABLE file_names ADD COLUMN status TEXT DEFAULT 'not started';",
); );
db.exec("PRAGMA user_version = 1;"); db.exec("PRAGMA user_version = 1;");
console.log("Updated database to version 1.");
} }
let FIRST_RUN = db.query("SELECT * FROM users").get() === null || false; let FIRST_RUN = db.query("SELECT * FROM users").get() === null || false;
@@ -454,7 +458,7 @@ const app = new Elysia()
<optgroup label={converter}> <optgroup label={converter}>
{targets.map((target) => ( {targets.map((target) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation> // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<option value={`${target},${converter}`}>{target}</option> <option value={`${target},${converter}`} safe>{target}</option>
))} ))}
</optgroup> </optgroup>
))} ))}
@@ -481,7 +485,7 @@ const app = new Elysia()
<optgroup label={converter}> <optgroup label={converter}>
{targets.map((target) => ( {targets.map((target) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation> // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<option value={`${target},${converter}`}>{target}</option> <option value={`${target},${converter}`} safe>{target}</option>
))} ))}
</optgroup> </optgroup>
), ),
@@ -717,10 +721,10 @@ const app = new Elysia()
{userJobs.map((job) => ( {userJobs.map((job) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation> // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<tr> <tr>
<td>{job.date_created}</td> <td safe>{job.date_created}</td>
<td>{job.num_files}</td> <td>{job.num_files}</td>
<td>{job.finished_files}</td> <td>{job.finished_files}</td>
<td>{job.status}</td> <td safe>{job.status}</td>
<td> <td>
<a href={`/results/${job.id}`}>View</a> <a href={`/results/${job.id}`}>View</a>
</td> </td>
@@ -798,8 +802,8 @@ const app = new Elysia()
{files.map((file) => ( {files.map((file) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation> // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<tr> <tr>
<td>{file.output_file_name}</td> <td safe>{file.output_file_name}</td>
<td>{file.status}</td> <td safe>{file.status}</td>
<td> <td>
<a <a
href={`/download/${outputPath}${file.output_file_name}`}> href={`/download/${outputPath}${file.output_file_name}`}>
@@ -886,8 +890,8 @@ const app = new Elysia()
{files.map((file) => ( {files.map((file) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation> // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<tr> <tr>
<td>{file.output_file_name}</td> <td safe>{file.output_file_name}</td>
<td>{file.status}</td> <td safe>{file.status}</td>
<td> <td>
<a href={`/download/${outputPath}${file.output_file_name}`}> <a href={`/download/${outputPath}${file.output_file_name}`}>
View View
@@ -966,13 +970,13 @@ const app = new Elysia()
return ( return (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation> // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<tr> <tr>
<td>{converter}</td> <td safe>{converter}</td>
<td> <td>
Count: {inputs.length} Count: {inputs.length}
<ul> <ul>
{inputs.map((input) => ( {inputs.map((input) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation> // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<li>{input}</li> <li safe>{input}</li>
))} ))}
</ul> </ul>
</td> </td>
@@ -981,7 +985,7 @@ const app = new Elysia()
<ul> <ul>
{targets.map((target) => ( {targets.map((target) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation> // biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<li>{target}</li> <li safe>{target}</li>
))} ))}
</ul> </ul>
</td> </td>