refactor: renaming
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
import IJob from './IJob';
|
import IJob from './IJob';
|
||||||
import MangaUpdateCacheRenewService from '../service/MangaUpdateCacheRenewService.js';
|
import MangaUpdatesCacheRenewService from '../service/MangaUpdatesCacheRenewService';
|
||||||
import {MangaUpdatesCache} from '../cache/MangaUpdatesCache.js';
|
import {MangaUpdatesCache} from '../cache/MangaUpdatesCache.js';
|
||||||
|
|
||||||
export default class MangaUpdateCacheRenewJob implements IJob<void> {
|
export default class MangaUpdatesCacheRenewJob implements IJob<void> {
|
||||||
private readonly service: MangaUpdateCacheRenewService;
|
private readonly service: MangaUpdatesCacheRenewService;
|
||||||
private lock: boolean = false;
|
private lock: boolean = false;
|
||||||
|
|
||||||
constructor(cache: MangaUpdatesCache) {
|
constructor(cache: MangaUpdatesCache) {
|
||||||
this.service = new MangaUpdateCacheRenewService(cache);
|
this.service = new MangaUpdatesCacheRenewService(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
get schedule(): Date | string {
|
get schedule(): Date | string {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import {MangaUpdatesCache} from '../cache/MangaUpdatesCache.js';
|
import {MangaUpdatesCache} from '../cache/MangaUpdatesCache.js';
|
||||||
import IJob from './IJob.js';
|
import IJob from './IJob.js';
|
||||||
import MangaUpdateCacheRenewJob from './MangaUpdateCacheRenewJob.js';
|
import MangaUpdatesCacheRenewJob from './MangaUpdatesCacheRenewJob';
|
||||||
import {gracefulShutdown, scheduleJob} from 'node-schedule';
|
import {gracefulShutdown, scheduleJob} from 'node-schedule';
|
||||||
import {MangaDexCache} from '../cache/MangaDexCache';
|
import {MangaDexCache} from '../cache/MangaDexCache';
|
||||||
import MangaDexCacheRenewJob from './MangaDexCacheRenewJob';
|
import MangaDexCacheRenewJob from './MangaDexCacheRenewJob';
|
||||||
@@ -11,7 +11,7 @@ export default class Scheduler {
|
|||||||
constructor(mangaDexCache: MangaDexCache, mangaUpdatesCache: MangaUpdatesCache) {
|
constructor(mangaDexCache: MangaDexCache, mangaUpdatesCache: MangaUpdatesCache) {
|
||||||
this.jobs.push(
|
this.jobs.push(
|
||||||
new MangaDexCacheRenewJob(mangaDexCache),
|
new MangaDexCacheRenewJob(mangaDexCache),
|
||||||
new MangaUpdateCacheRenewJob(mangaUpdatesCache),
|
new MangaUpdatesCacheRenewJob(mangaUpdatesCache),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {MangaUpdatesCache} from '../cache/MangaUpdatesCache';
|
import {MangaUpdatesCache} from '../cache/MangaUpdatesCache';
|
||||||
|
|
||||||
export default class MangaUpdateCacheRenewService {
|
export default class MangaUpdatesCacheRenewService {
|
||||||
private static readonly delay = 3000;
|
private static readonly delay = 3000;
|
||||||
|
|
||||||
private readonly cache: MangaUpdatesCache;
|
private readonly cache: MangaUpdatesCache;
|
||||||
@@ -22,7 +22,7 @@ export default class MangaUpdateCacheRenewService {
|
|||||||
console.log(titles.length + ' out-of-date relations');
|
console.log(titles.length + ' out-of-date relations');
|
||||||
|
|
||||||
for (let title of titles) {
|
for (let title of titles) {
|
||||||
await new Promise((r) => setTimeout(r, MangaUpdateCacheRenewService.delay));
|
await new Promise((r) => setTimeout(r, MangaUpdatesCacheRenewService.delay));
|
||||||
try {
|
try {
|
||||||
const fromApi = await fetch('https://api.mangaupdates.com/v1/series/search', {
|
const fromApi = await fetch('https://api.mangaupdates.com/v1/series/search', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -49,7 +49,7 @@ export default class MangaUpdateCacheRenewService {
|
|||||||
console.log(ids.length + ' out-of-date series');
|
console.log(ids.length + ' out-of-date series');
|
||||||
|
|
||||||
for (let id of ids) {
|
for (let id of ids) {
|
||||||
await new Promise((r) => setTimeout(r, MangaUpdateCacheRenewService.delay));
|
await new Promise((r) => setTimeout(r, MangaUpdatesCacheRenewService.delay));
|
||||||
try {
|
try {
|
||||||
const fromApi = await fetch('https://api.mangaupdates.com/v1/series/' + id);
|
const fromApi = await fetch('https://api.mangaupdates.com/v1/series/' + id);
|
||||||
if (fromApi.status !== 200) {
|
if (fromApi.status !== 200) {
|
||||||
@@ -69,7 +69,7 @@ export default class MangaUpdateCacheRenewService {
|
|||||||
console.log(ids.length + ' out-of-date series updates');
|
console.log(ids.length + ' out-of-date series updates');
|
||||||
|
|
||||||
for (let id of ids) {
|
for (let id of ids) {
|
||||||
await new Promise((r) => setTimeout(r, MangaUpdateCacheRenewService.delay));
|
await new Promise((r) => setTimeout(r, MangaUpdatesCacheRenewService.delay));
|
||||||
try {
|
try {
|
||||||
const fromApi = await fetch('https://api.mangaupdates.com/v1/series/' + id + '/groups');
|
const fromApi = await fetch('https://api.mangaupdates.com/v1/series/' + id + '/groups');
|
||||||
if (fromApi.status !== 200) {
|
if (fromApi.status !== 200) {
|
||||||
Reference in New Issue
Block a user