Skip to content

Commit

Permalink
Implement PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyi committed Oct 31, 2024
1 parent d78be9f commit 740dc61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions adminSiteServer/multiDim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ async function getViewIdToChartConfigIdMap(
knex: db.KnexReadonlyTransaction,
slug: string
) {
const mapping = new Map<string, string>()
const rows = await db.knexRaw<DbPlainMultiDimXChartConfig>(
knex,
`-- sql
Expand All @@ -132,10 +131,7 @@ async function getViewIdToChartConfigIdMap(
WHERE mddp.slug = ?`,
[slug]
)
for (const { viewId, chartConfigId } of rows) {
mapping.set(viewId, chartConfigId)
}
return mapping
return new Map(rows.map((row) => [row.viewId, row.chartConfigId]))
}

async function saveNewMultiDimViewChartConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class AddMultiDimIdConfigMd5SlugIndex1729600015045
await queryRunner.query(`-- sql
ALTER TABLE multi_dim_data_pages
DROP PRIMARY KEY,
ADD COLUMN id SERIAL PRIMARY KEY FIRST,
ADD COLUMN id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
ADD COLUMN configMd5 CHAR(24) GENERATED ALWAYS as (to_base64(unhex(md5(config)))) STORED NOT NULL AFTER config
`)
await queryRunner.query(`-- sql
Expand Down
4 changes: 2 additions & 2 deletions db/migration/1729684787090-CreateMultiDimXChartConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export class CreateMultiDimXChartConfigs1729684787090
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`-- sql
CREATE TABLE multi_dim_x_chart_configs (
id SERIAL PRIMARY KEY,
multiDimId BIGINT UNSIGNED NOT NULL,
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
multiDimId INT UNSIGNED NOT NULL,
viewId VARCHAR(255) NOT NULL,
variableId INT NOT NULL,
chartConfigId CHAR(36) NOT NULL UNIQUE,
Expand Down

0 comments on commit 740dc61

Please sign in to comment.