diff --git a/src/db/models/WasmCodeKeyId.ts b/src/db/models/WasmCodeKeyId.ts index 1db88e15..aa54e095 100644 --- a/src/db/models/WasmCodeKeyId.ts +++ b/src/db/models/WasmCodeKeyId.ts @@ -3,7 +3,6 @@ import { BelongsTo, Column, Model, - PrimaryKey, Table, } from 'sequelize-typescript' @@ -19,10 +18,6 @@ import { WasmCodeKey } from './WasmCodeKey' ], }) export class WasmCodeKeyId extends Model { - @PrimaryKey - @Column - declare id: number - @AllowNull(false) @Column declare codeKey: string diff --git a/src/services/wasm-codes/wasm-code.service.test.ts b/src/services/wasm-codes/wasm-code.service.test.ts index 4e3feab0..6bd64193 100644 --- a/src/services/wasm-codes/wasm-code.service.test.ts +++ b/src/services/wasm-codes/wasm-code.service.test.ts @@ -19,7 +19,7 @@ describe('WasmCodeService tests', () => { } await WasmCodeKey.createFromKeyAndIds('codeKey1', [1, 2, 3]) - await WasmCodeKey.createFromKeyAndIds('codeKey2', [4, 5, 6]) + await WasmCodeKey.createFromKeyAndIds('codeKey2', [4, 5, 6, 5, 5, 5]) await WasmCodeKey.createFromKeyAndIds('codeKey3', [1, 3, 5]) await wasmCodeService.reloadWasmCodeIdsFromDB() diff --git a/src/services/wasm-codes/wasm-code.service.ts b/src/services/wasm-codes/wasm-code.service.ts index b885e813..75efe49f 100644 --- a/src/services/wasm-codes/wasm-code.service.ts +++ b/src/services/wasm-codes/wasm-code.service.ts @@ -136,10 +136,15 @@ export class WasmCodeService implements WasmCodeAdapter { } /** - * Return a copy of the list of wasm codes. + * Return a sorted list of wasm codes with sorted IDs. */ getWasmCodes(): WasmCode[] { - return [...this.wasmCodes] + return this.wasmCodes + .map( + (wasmCode: WasmCode) => + new WasmCode(wasmCode.codeKey, wasmCode.codeIds.sort()) + ) + .sort((a, b) => a.codeKey.localeCompare(b.codeKey)) } /**