Commit 6a30bfa6 authored by nanahira's avatar nanahira

remove archive.files col

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