Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: songs from external collections are treated as internal #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/engine/1.6/engine-db-1_6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class EngineDB_1_6 extends EngineDB {
trackId: track.id,
trackIdInOriginDatabase: track.id,
trackNumber: i + 1,
databaseUuid: this.databaseUuid,
databaseUuid: this.uuid,
})),
);
}
Expand All @@ -107,7 +107,11 @@ export class EngineDB_1_6 extends EngineDB {
async getTracks(): Promise<publicSchema.Track[]> {
const tracks = await this.getTracksInternal();

return tracks.map(track => ({ ...track, ...track.meta }));
return tracks.map(track => ({
...track,
...track.meta,
isBeatGridLocked: !!track.isBeatGridLocked,
}));
}

private async getTracksInternal(): Promise<schema.TrackWithMeta[]> {
Expand All @@ -124,7 +128,8 @@ export class EngineDB_1_6 extends EngineDB {
'trackType',
'year',
])
.whereNotNull('path');
.whereNotNull('path')
.andWhere('isExternalTrack', 0);
const textMetas = await this.table('MetaData').select('*');
const textMetaMap = groupBy(textMetas, x => x.id);
const intMetas = await this.table('MetaDataInteger').select('*');
Expand Down
4 changes: 2 additions & 2 deletions src/engine/1.6/schema-1_6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export interface Track {
bitrate: number;
bpmAnalyzed: number;
filename: string;
isBeatGridLocked: boolean;
isExternalTrack: boolean;
isBeatGridLocked: IntBoolean;
isExternalTrack: IntBoolean;
length: number;
path: string;
trackType: TrackType;
Expand Down
5 changes: 3 additions & 2 deletions src/engine/2.0/engine-db-2_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class EngineDB_2_0 extends EngineDB {
? 0
: lastEntityId + 2 + i,
membershipReference: 0,
databaseUuid: this.databaseUuid,
databaseUuid: this.uuid,
})),
);
}
Expand Down Expand Up @@ -150,7 +150,8 @@ export class EngineDB_2_0 extends EngineDB {
'title',
'year',
])
.whereNotNull('path');
.whereNotNull('path')
.andWhere('originDatabaseUuid', this.uuid);
}

async updateTrackPaths(tracks: publicSchema.Track[]) {
Expand Down
10 changes: 6 additions & 4 deletions src/engine/engine-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import { EngineVersion } from './version-detection';
export abstract class EngineDB {
protected readonly knex: Knex;

protected databaseUuid!: string;
protected schemaInfo!: schema.Information;

abstract get version(): EngineVersion;

get uuid(): string {
return this.schemaInfo.uuid;
}

protected constructor(private readonly dbPath: string) {
this.knex = knex({
client: 'sqlite3',
Expand All @@ -22,9 +26,7 @@ export abstract class EngineDB {

protected async init() {
await this.backup();
const { uuid } = await this.getSchemaInfo();

this.databaseUuid = uuid;
this.schemaInfo = await this.getSchemaInfo();
}

async disconnect() {
Expand Down