Skip to content

Commit

Permalink
Use projectSlug for naming data files
Browse files Browse the repository at this point in the history
Projects are created in `recordProject()` with

INSERT INTO Project (name, slug)
  VALUES ($1, regexp_replace($2, '[^0-9a-zA-Z-]', '-', 'g'))
  RETURNING *

This means, all none number and a-z characters are replaced with - and made safe.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information
smarr committed Apr 3, 2024
1 parent f84de3f commit 23831ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/backend/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ export abstract class Database {
projectSlug: string
): Promise<{
project: string;
projectSlug: string;
expName: string;
expDesc: string;
projectId: number;
Expand All @@ -729,7 +730,8 @@ export abstract class Database {
exp.description as expDesc,
p.id as pId,
p.name as pName,
p.description as pDesc
p.description as pDesc,
p.slug as pSlug
FROM
Experiment exp
JOIN Project p ON exp.projectId = p.id
Expand All @@ -744,6 +746,7 @@ export abstract class Database {

return {
project: result.rows[0].pname,
projectSlug: result.rows[0].pslug,
expName: result.rows[0].expname,
expDesc: result.rows[0].expDesc,
projectId: result.rows[0].pid,
Expand Down
3 changes: 2 additions & 1 deletion src/backend/project/data-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ export async function getExpData(
if (!result) {
data = {
project: '',
projectSlug,
generationFailed: true,
stdout: 'Experiment was not found'
};
} else {
data = result;
}

const expFilePrefix = `${data.project}-${expId}`;
const expFilePrefix = `${data.projectSlug}-${expId}`;
const expFileName = `${expFilePrefix}.${format}.gz`;

if (existsSync(`${siteConfig.dataExportPath}/${expFileName}`)) {
Expand Down

0 comments on commit 23831ae

Please sign in to comment.