fix(backend): restore date properly of federated instance cache

This commit is contained in:
syuilo 2023-04-07 18:55:11 +09:00
parent 1377ea4178
commit ed4a100e96
1 changed files with 9 additions and 1 deletions

View File

@ -27,7 +27,15 @@ export class FederatedInstanceService {
memoryCacheLifetime: 1000 * 60 * 30, // 30m memoryCacheLifetime: 1000 * 60 * 30, // 30m
fetcher: (key) => this.instancesRepository.findOneBy({ host: key }), fetcher: (key) => this.instancesRepository.findOneBy({ host: key }),
toRedisConverter: (value) => JSON.stringify(value), toRedisConverter: (value) => JSON.stringify(value),
fromRedisConverter: (value) => JSON.parse(value), // TODO: date型の考慮 fromRedisConverter: (value) => {
const parsed = JSON.parse(value);
return {
...parsed,
firstRetrievedAt: new Date(parsed.firstRetrievedAt),
latestRequestReceivedAt: parsed.latestRequestReceivedAt ? new Date(parsed.latestRequestReceivedAt) : null,
infoUpdatedAt: parsed.infoUpdatedAt ? new Date(parsed.infoUpdatedAt) : null,
};
},
}); });
} }