Skip to content

Commit

Permalink
Remove unused Unit table (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed Feb 25, 2024
2 parents 757dc03 + b3360cd commit aa291ef
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
10 changes: 1 addition & 9 deletions src/backend/db/db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ CREATE TABLE Environment (
note text
);

-- The unit of a measure.
CREATE TABLE Unit (
name varchar primary key,
description text,
lessIsBetter boolean
);

-- A specific criterion that is measured for a benchmark.
-- This can be anything, from total time over memory consumption
-- to other things or parts worth measuring.
Expand All @@ -37,8 +30,7 @@ CREATE TABLE Criterion (
name varchar,
unit varchar,

unique (name, unit),
foreign key (unit) references Unit (name)
unique (name, unit)
);

-- Groups all the data that belongs together.
Expand Down
16 changes: 0 additions & 16 deletions src/backend/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,29 +828,13 @@ export abstract class Database {
return exp;
}

private async recordUnit(unitName: string) {
const result = await this.query({
name: 'fetchUnitByName',
text: 'SELECT * from Unit WHERE name = $1',
values: [unitName]
});
if (result.rowCount === 0) {
await this.query({
name: 'insertUnit',
text: 'INSERT INTO Unit (name) VALUES ($1)',
values: [unitName]
});
}
}

public async recordCriterion(c: ApiCriterion): Promise<Criterion> {
const cacheKey = `${c.c}::${c.u}`;

if (this.criteria.has(cacheKey)) {
return <Criterion>this.criteria.get(cacheKey);
}

await this.recordUnit(c.u);
return this.recordCached(
this.criteria,
cacheKey,
Expand Down

0 comments on commit aa291ef

Please sign in to comment.