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 { ...@@ -25,7 +25,9 @@ export class UpdateService extends ConsoleLogger {
} }
async getAppsJson() { 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( private async getBuild(
...@@ -82,7 +84,7 @@ export class UpdateService extends ConsoleLogger { ...@@ -82,7 +84,7 @@ export class UpdateService extends ConsoleLogger {
} }
async getChecksum(id: string, depotDto: DepotDto, version: string) { 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 { return {
files: Object.entries(build.checksum) files: Object.entries(build.checksum)
// .filter(([name, hash]) => file.length && hash !== null) // .filter(([name, hash]) => file.length && hash !== null)
...@@ -92,7 +94,7 @@ export class UpdateService extends ConsoleLogger { ...@@ -92,7 +94,7 @@ export class UpdateService extends ConsoleLogger {
async getFullPackageMetalink(id: string, depotDto: DepotDto, version: string) { async getFullPackageMetalink(id: string, depotDto: DepotDto, version: string) {
const archives = await this.getArchives(id, depotDto, version, (qb) => 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 { return {
cdnUrl: this.cdnUrl, cdnUrl: this.cdnUrl,
...@@ -138,7 +140,12 @@ export class UpdateService extends ConsoleLogger { ...@@ -138,7 +140,12 @@ 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', 'archive.id'])
.leftJoin('build.archives', 'archive', 'archive.role = :partRole', { partRole: ArchiveType.Part })
);
console.log(build.archives);
//let clock = moment(); //let clock = moment();
//this.log('part 1'); //this.log('part 1');
const tryExactArchiveQuery = this.db const tryExactArchiveQuery = this.db
...@@ -159,7 +166,7 @@ export class UpdateService extends ConsoleLogger { ...@@ -159,7 +166,7 @@ export class UpdateService extends ConsoleLogger {
.subQuery() .subQuery()
.select('file.path') .select('file.path')
.from(ArchiveFile, 'file') .from(ArchiveFile, 'file')
.where('file.archiveId = archive.id') .andWhere('file.archiveId = archive.id')
.getQuery()})`, .getQuery()})`,
{ requestedFiles: requestedFiles } { requestedFiles: requestedFiles }
) )
...@@ -202,7 +209,8 @@ export class UpdateService extends ConsoleLogger { ...@@ -202,7 +209,8 @@ export class UpdateService extends ConsoleLogger {
.subQuery() .subQuery()
.select('distinct(file.archiveId)') .select('distinct(file.archiveId)')
.from(ArchiveFile, 'file') .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()})` .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