Commit c56eb3b5 authored by nanahira's avatar nanahira

clean

parent aae254ce
......@@ -212,16 +212,7 @@ export class UpdateService extends ConsoleLogger {
if (!requestedFiles || !requestedFiles.length) {
throw new BlankReturnMessageDto(400, 'empty files').toException();
}
const build = await this.getBuild(
id,
depotDto,
version,
(qb) => qb.select('build.id')
//.leftJoin('build.archives', 'archive', 'archive.role = :partRole', { partRole: ArchiveType.Part })
);
// console.log(build.archives);
//let clock = moment();
//this.log('part 1');
const build = await this.getBuild(id, depotDto, version, (qb) => qb.select('build.id'));
const tryExactArchiveQuery = this.db
.getRepository(Archive)
.createQueryBuilder('archive')
......@@ -229,23 +220,6 @@ export class UpdateService extends ConsoleLogger {
.where('archive.buildId = :buildId', { buildId: build.id })
.andWhere('archive.role != :partRole', { partRole: ArchiveType.Part })
.andWhere(':requestedFiles = archive.files', { requestedFiles })
/*.addSelect(`array(${qb
.subQuery()
.select('file.path')
.from(ArchiveFile, 'file')
.where('file.archiveId = archive.id')
.getQuery()})`, 'allFiles')
tryExactArchiveQuery
.andWhere(
`:requestedFiles = array(${tryExactArchiveQuery
.subQuery()
.select('file.path')
.from(ArchiveFile, 'file')
.where('file.archiveId = archive.id')
.getQuery()})`,
{ requestedFiles: requestedFiles }
)*/
// .orderBy('archive.size', 'ASC')
.limit(1);
const tryExactArchives = await tryExactArchiveQuery.getMany();
if (tryExactArchives.length) {
......@@ -254,22 +228,7 @@ export class UpdateService extends ConsoleLogger {
archives: tryExactArchives,
};
}
//this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
/*clock = moment();
this.log('part ex');
const archiveIds: number[] = (
await this.db
.createQueryBuilder()
.select('distinct(file.archiveId)', 'archiveId')
.from(ArchiveFile, 'file')
.where('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles })
.innerJoin('file.archive', 'archive')
.andWhere('archive.buildId = :buildId', { buildId: build.id })
.getRawMany()
).map((obj) => obj.archiveId);*/
//this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
//clock = moment();
//this.log('part 2');
const allPossiblePartArchives = await this.db
.getRepository(Archive)
.createQueryBuilder('archive')
......@@ -277,29 +236,8 @@ export class UpdateService extends ConsoleLogger {
.where('archive.buildId = :buildId', { buildId: build.id })
.andWhere('archive.role = :partRole', { partRole: ArchiveType.Part })
.getMany();
//.innerJoin('archive.containingFiles', 'file')
//.andWhere('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles });
/*
allPartArchivesQuery.andWhere(
`archive.id in (${allPartArchivesQuery
.subQuery()
.select('distinct(file.archiveId)')
.from(ArchiveFile, 'file')
.where('file.archiveId = any(:possibleArchiveIds)', { possibleArchiveIds: build.archives.map((a) => a.id) })
.andWhere('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');
const allPartArchives = this.pickArchives(allPossiblePartArchives, requestedFiles);
//this.log(`Time used: ${moment().diff(clock, 'seconds')} s`);
//clock = moment();
//this.log('part 4');
const fullArchive = await this.db
.getRepository(Archive)
.createQueryBuilder('archive')
......@@ -314,7 +252,6 @@ export class UpdateService extends ConsoleLogger {
archives = [fullArchive];
}
await this.mirror.lookForArchivesMirror(archives);
//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