Commit 6a30bfa6 authored by nanahira's avatar nanahira

remove archive.files col

parent 14ce01b4
......@@ -15,8 +15,8 @@ export class Archive extends TimeBase {
@PrimaryGeneratedColumn({ type: 'int8' })
id: number;
@Column('varchar', { length: 256, array: true })
files: string[];
//@Column('varchar', { length: 256, array: true })
//files: string[];
@OneToMany(() => ArchiveFile, (file) => file.archive, { cascade: true })
containingFiles: ArchiveFile[];
......
......@@ -47,7 +47,7 @@ export class ArchiveTask {
const archive = new Archive();
archive.path = this.path;
archive.role = this.role;
archive.files = this.exactFilePaths;
//archive.files = this.exactFilePaths;
archive.containingFiles = this.exactFilePaths.map((filePath) => ArchiveFile.fromPath(filePath));
return archive;
}
......
......@@ -139,8 +139,8 @@ export class UpdateService extends ConsoleLogger {
async getPartPackageMetalink(id: string, depotDto: DepotDto, version: string, requestedFiles: string[]) {
const build = await this.getBuild(id, depotDto, version, (qb) => qb.select('build.id'));
let clock = moment();
this.log('part 1');
//let clock = moment();
//this.log('part 1');
const tryExactArchiveQuery = this.db
.getRepository(Archive)
.createQueryBuilder('archive')
......@@ -172,7 +172,7 @@ export class UpdateService extends ConsoleLogger {
archives: tryExactArchives,
};
}
this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
//this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
/*clock = moment();
this.log('part ex');
const archiveIds: number[] = (
......@@ -186,8 +186,8 @@ export class UpdateService extends ConsoleLogger {
.getRawMany()
).map((obj) => obj.archiveId);
this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);*/
clock = moment();
this.log('part 2');
//clock = moment();
//this.log('part 2');
const allPartArchivesQuery = this.db
.getRepository(Archive)
.createQueryBuilder('archive')
......@@ -198,19 +198,18 @@ export class UpdateService extends ConsoleLogger {
//.andWhere('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles });
allPartArchivesQuery.andWhere(
`exists ${allPartArchivesQuery
`archive.id in (${allPartArchivesQuery
.subQuery()
.select('file.path')
.select('distinct(file.archiveId)')
.from(ArchiveFile, 'file')
.where('file.archiveId = archive.id')
.andWhere('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles })
.getQuery()}`
.where('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles })
.getQuery()})`
);
const allPartArchives = await allPartArchivesQuery.getMany();
this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
clock = moment();
this.log('part 3');
//this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
//clock = moment();
//this.log('part 3');
const fullArchive = await this.db
.getRepository(Archive)
.createQueryBuilder('archive')
......@@ -224,7 +223,7 @@ export class UpdateService extends ConsoleLogger {
if (fullArchive && this.getCostOfArchives([fullArchive]) <= this.getCostOfArchives(allPartArchives)) {
archives = [fullArchive];
}
this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
//this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
return {
cdnUrl: this.cdnUrl,
archives,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment