Commit eaabbdb4 authored by nanahira's avatar nanahira

optimize

parent b224a62c
Pipeline #4937 failed with stages
in 1 minute and 26 seconds
......@@ -25,7 +25,9 @@ export class UpdateService extends ConsoleLogger {
}
async getAppsJson() {
return (await this.db.getRepository(App).find({ where: { appData: Not(IsNull()), isDeleted: false } })).map((a) => a.displayData);
return (await this.db.getRepository(App).find({ where: { appData: Not(IsNull()), isDeleted: false }, select: ['appData'] })).map(
(a) => a.displayData
);
}
private async getBuild(
......@@ -82,7 +84,7 @@ export class UpdateService extends ConsoleLogger {
}
async getChecksum(id: string, depotDto: DepotDto, version: string) {
const build = await this.getBuild(id, depotDto, version);
const build = await this.getBuild(id, depotDto, version, (qb) => qb.select('build.checksum'));
return {
files: Object.entries(build.checksum)
// .filter(([name, hash]) => file.length && hash !== null)
......@@ -92,7 +94,7 @@ export class UpdateService extends ConsoleLogger {
async getFullPackageMetalink(id: string, depotDto: DepotDto, version: string) {
const archives = await this.getArchives(id, depotDto, version, (qb) =>
qb.andWhere('archive.role = :fullRole', { fullRole: ArchiveType.Full })
qb.select(['archive.hash', 'archive.path', 'archive.size']).andWhere('archive.role = :fullRole', { fullRole: ArchiveType.Full })
);
return {
cdnUrl: this.cdnUrl,
......@@ -138,7 +140,12 @@ 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'));
const build = await this.getBuild(id, depotDto, version, (qb) =>
qb
.select(['build.id', 'archive.id'])
.leftJoin('build.archives', 'archive', 'archive.role = :partRole', { partRole: ArchiveType.Part })
);
console.log(build.archives);
//let clock = moment();
//this.log('part 1');
const tryExactArchiveQuery = this.db
......@@ -159,7 +166,7 @@ export class UpdateService extends ConsoleLogger {
.subQuery()
.select('file.path')
.from(ArchiveFile, 'file')
.where('file.archiveId = archive.id')
.andWhere('file.archiveId = archive.id')
.getQuery()})`,
{ requestedFiles: requestedFiles }
)
......@@ -202,7 +209,8 @@ export class UpdateService extends ConsoleLogger {
.subQuery()
.select('distinct(file.archiveId)')
.from(ArchiveFile, 'file')
.where('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles })
.where('file.archiveId = any(:possibleArchiveIds)', { possibleArchiveIds: build.archives.map((a) => a.id) })
.andWhere('file.path = any(:requestedFiles)', { requestedFiles: requestedFiles })
.getQuery()})`
);
......
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