mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-08-23 00:54:21 -05:00
Rename archive generator to compressor
This commit is contained in:
@@ -4,7 +4,7 @@ import { update } from './data/index.mjs';
|
||||
import { warmCaches } from './splatnet/index.mjs';
|
||||
import { sendStatuses } from './social/index.mjs';
|
||||
import { archiveData } from './data/DataArchiver.mjs';
|
||||
import { generateArchives } from './data/ArchiveGenerator.mjs';
|
||||
import { compressArchives } from './data/ArchiveCompressor.mjs';
|
||||
import { updateAvatars } from './social/updateAvatars.mjs';
|
||||
|
||||
let updating = false;
|
||||
@@ -63,6 +63,6 @@ export default function() {
|
||||
}, null, true);
|
||||
|
||||
new CronJob('30 * * * *', updateAvatars, null, true);
|
||||
new CronJob('30 0 * * *', () => generateArchives(10), null, true, 'UTC');
|
||||
new CronJob('30 0 * * *', () => compressArchives(10), null, true, 'UTC');
|
||||
new CronJob('0 55 4 * * *', restartToRefreshConfig, null, true);
|
||||
}
|
||||
|
||||
@@ -38,15 +38,15 @@ function processCompletion(child, name) {
|
||||
});
|
||||
}
|
||||
|
||||
export function generateArchives(maxDays = Infinity, dryRun = false) {
|
||||
let generator = new ArchiveGenerator;
|
||||
generator.maxDays = maxDays;
|
||||
generator.dryRun = dryRun;
|
||||
export function compressArchives(maxDays = Infinity, dryRun = false) {
|
||||
let compressor = new ArchiveCompressor;
|
||||
compressor.maxDays = maxDays;
|
||||
compressor.dryRun = dryRun;
|
||||
|
||||
return generator.process();
|
||||
return compressor.process();
|
||||
}
|
||||
|
||||
export function generateArchivesFromCli(args) {
|
||||
export function compressArchivesFromCli(args) {
|
||||
let dryRun = false;
|
||||
let maxDays = Infinity;
|
||||
|
||||
@@ -57,7 +57,7 @@ export function generateArchivesFromCli(args) {
|
||||
maxDays = Number(args[++i]);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Usage: npm run data:archive:generate -- [--dry-run] [--max-days DAYS]',
|
||||
'Usage: npm run data:archive:compress -- [--dry-run] [--max-days DAYS]',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -66,30 +66,30 @@ export function generateArchivesFromCli(args) {
|
||||
throw new Error('--max-days must be at least 1');
|
||||
}
|
||||
|
||||
return generateArchives(maxDays, dryRun);
|
||||
return compressArchives(maxDays, dryRun);
|
||||
}
|
||||
|
||||
export default class ArchiveGenerator
|
||||
export default class ArchiveCompressor
|
||||
{
|
||||
dryRun = false;
|
||||
maxDays = Infinity;
|
||||
|
||||
async process() {
|
||||
if (!this.canRun) {
|
||||
this.console.log('Skipping archive generator');
|
||||
this.console.log('Skipping archive compressor');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let currentDate;
|
||||
let generated = 0;
|
||||
let compressed = 0;
|
||||
|
||||
try {
|
||||
let candidates = await this.getCandidates();
|
||||
this.console.log(`Found ${candidates.length} dates to archive`);
|
||||
|
||||
for (let candidate of candidates) {
|
||||
if (generated >= this.maxDays) {
|
||||
if (compressed >= this.maxDays) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ export default class ArchiveGenerator
|
||||
? await this.previewDate(candidate)
|
||||
: await this.archiveDate(candidate);
|
||||
if (completed) {
|
||||
generated++;
|
||||
compressed++;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -114,14 +114,16 @@ export default class ArchiveGenerator
|
||||
}
|
||||
|
||||
this.console.log(
|
||||
this.dryRun ? `Would generate ${generated} archives` : `Generated ${generated} archives`,
|
||||
this.dryRun
|
||||
? `Would compress ${compressed} daily archives`
|
||||
: `Compressed ${compressed} daily archives`,
|
||||
);
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
||||
get console() {
|
||||
this._console ??= prefixedConsole('Archive Generator');
|
||||
this._console ??= prefixedConsole('Archive Compressor');
|
||||
|
||||
return this._console;
|
||||
}
|
||||
@@ -147,7 +149,7 @@ export default class ArchiveGenerator
|
||||
});
|
||||
}
|
||||
|
||||
// Archive generation
|
||||
// Archive compression
|
||||
|
||||
async previewDate(candidate) {
|
||||
let objects = await this.getReadyObjects(candidate);
|
||||
@@ -156,7 +158,7 @@ export default class ArchiveGenerator
|
||||
}
|
||||
|
||||
this.console.log(
|
||||
`Would generate ${candidate.archiveKey} and ${candidate.manifestKey} `
|
||||
`Would create ${candidate.archiveKey} and ${candidate.manifestKey} `
|
||||
+ `from ${objects.length} files`,
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ import ImageWriter from './social/clients/ImageWriter.mjs';
|
||||
import BlueskyClient from './social/clients/BlueskyClient.mjs';
|
||||
import ThreadsClient from './social/clients/ThreadsClient.mjs';
|
||||
import { archiveData } from './data/DataArchiver.mjs';
|
||||
import { generateArchivesFromCli } from './data/ArchiveGenerator.mjs';
|
||||
import { compressArchivesFromCli } from './data/ArchiveCompressor.mjs';
|
||||
import { sentryInit } from './common/sentry.mjs';
|
||||
import { sync, syncUpload, syncDownload } from './sync/index.mjs';
|
||||
import { updateAvatars } from './social/updateAvatars.mjs';
|
||||
@@ -29,7 +29,7 @@ const actions = {
|
||||
splatnet: update,
|
||||
warmCaches,
|
||||
dataArchive: archiveData,
|
||||
archiveGenerate: (...args) => generateArchivesFromCli(args),
|
||||
archiveCompress: (...args) => compressArchivesFromCli(args),
|
||||
sync,
|
||||
syncUpload,
|
||||
syncDownload,
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
"splatnet:all": "node app/index.mjs splatnet all",
|
||||
"warmCaches": "node app/index.mjs warmCaches",
|
||||
"data:archive": "node app/index.mjs dataArchive",
|
||||
"data:archive:generate": "node app/index.mjs archiveGenerate",
|
||||
"data:archive:generate:dry-run": "node app/index.mjs archiveGenerate --dry-run",
|
||||
"data:archive:compress": "node app/index.mjs archiveCompress",
|
||||
"data:archive:compress:dry-run": "node app/index.mjs archiveCompress --dry-run",
|
||||
"sync": "node app/index.mjs sync",
|
||||
"sync:upload": "node app/index.mjs syncUpload",
|
||||
"sync:download": "node app/index.mjs syncDownload"
|
||||
|
||||
Reference in New Issue
Block a user