Commit c7ee525a authored by nanahira's avatar nanahira

ignore version field entirely

parent 6e3b109c
Pipeline #15348 canceled with stages
in 2 minutes and 46 seconds
...@@ -30,6 +30,7 @@ export class UpdateService extends ConsoleLogger { ...@@ -30,6 +30,7 @@ export class UpdateService extends ConsoleLogger {
(a) => a.displayData (a) => a.displayData
); );
const appVersionCacheMap = new Map<string, string>(); const appVersionCacheMap = new Map<string, string>();
const foundApps = new Set<string>();
for (const _platform of Object.values(AppsJson.Platform)) { for (const _platform of Object.values(AppsJson.Platform)) {
const platform = _platform as AppsJson.Platform; const platform = _platform as AppsJson.Platform;
if (platform === 'generic') { if (platform === 'generic') {
...@@ -41,40 +42,41 @@ export class UpdateService extends ConsoleLogger { ...@@ -41,40 +42,41 @@ export class UpdateService extends ConsoleLogger {
depotDto.platform = platform;*/ depotDto.platform = platform;*/
// this.log(platform); // this.log(platform);
for (const app of data) { for (const app of data) {
if (app.version?.[platform]) { app.version ??= {};
// this.log(`Try fetching latest version of ${app.id} ${platform}`); const tryCache = appVersionCacheMap.get(app.id);
const tryCache = appVersionCacheMap.get(app.id); if (tryCache) {
if (tryCache) { app.version[platform] = tryCache;
app.version[platform] = tryCache; }
}
const latestBuild = await this.db const latestBuild = await this.db
.getRepository(Build) .getRepository(Build)
.createQueryBuilder('build') .createQueryBuilder('build')
.select(['build.version', 'build.id', 'depot.platform']) .select(['build.version', 'build.id', 'depot.platform'])
.innerJoin('build.depot', 'depot') .innerJoin('build.depot', 'depot')
.where('depot.appId = :appId', { appId: app.id }) .where('depot.appId = :appId', { appId: app.id })
.andWhere( .andWhere(
new Brackets((qb) => new Brackets((qb) =>
qb qb
.where('depot.platform = :genericPlatform', { genericPlatform: Platform.generic }) .where('depot.platform = :genericPlatform', { genericPlatform: Platform.generic })
.orWhere('depot.platform = :platform', { platform }) .orWhere('depot.platform = :platform', { platform })
)
) )
.orderBy('build.id', 'DESC') )
.take(1) .orderBy('build.id', 'DESC')
.getOne(); .take(1)
if (latestBuild) { .getOne();
const latestVersion = latestBuild.version; if (latestBuild) {
if (latestBuild.depot.platform === 'generic') { if (!foundApps.has(app.id)) {
appVersionCacheMap.set(app.id, latestVersion); foundApps.add(app.id);
} }
app.version[platform] = latestVersion; const latestVersion = latestBuild.version;
if (latestBuild.depot.platform === 'generic') {
appVersionCacheMap.set(app.id, latestVersion);
} }
app.version[platform] = latestVersion;
} }
} }
} }
return data; return data.filter((app) => foundApps.has(app.id));
} }
private async getBuild( private async getBuild(
......
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