From 30fced38c49e19b5e1a7bb817b273b0a986dfa4c Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 16 Jan 2023 05:02:38 +0900 Subject: [PATCH] refactor: rename instance.caughtAt to instance.firstRetrievedAt --- CHANGELOG.md | 1 + .../migration/1673812883772-firstRetrievedAt.js | 11 +++++++++++ packages/backend/src/core/FederatedInstanceService.ts | 2 +- .../src/core/entities/InstanceEntityService.ts | 2 +- packages/backend/src/models/entities/Instance.ts | 2 +- .../backend/src/models/schema/federation-instance.ts | 2 +- .../src/server/api/endpoints/federation/instances.ts | 4 ++-- packages/frontend/src/pages/about.federation.vue | 4 ++-- packages/frontend/src/pages/admin/federation.vue | 4 ++-- packages/frontend/src/pages/instance-info.vue | 2 +- 10 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 packages/backend/migration/1673812883772-firstRetrievedAt.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aba40aef..cfd4640a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ You should also include the user name that made the change. - API: `user`および`note`エンティティに`emojis`プロパティが含まれなくなりました - API: `user`エンティティに`avatarColor`および`bannerColor`プロパティが含まれなくなりました - API: `instance`エンティティに`latestStatus`、`lastCommunicatedAt`、`latestRequestSentAt`プロパティが含まれなくなりました +- API: `instance`エンティティの`caughtAt`は`firstRetrievedAt`に名前が変わりました ### Improvements - Role system @syuilo diff --git a/packages/backend/migration/1673812883772-firstRetrievedAt.js b/packages/backend/migration/1673812883772-firstRetrievedAt.js new file mode 100644 index 000000000..5603bbc7c --- /dev/null +++ b/packages/backend/migration/1673812883772-firstRetrievedAt.js @@ -0,0 +1,11 @@ +export class firstRetrievedAt1673812883772 { + name = 'firstRetrievedAt1673812883772' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "instance" RENAME COLUMN "caughtAt" TO "firstRetrievedAt"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "instance" RENAME COLUMN "firstRetrievedAt" TO "caughtAt"`); + } +} diff --git a/packages/backend/src/core/FederatedInstanceService.ts b/packages/backend/src/core/FederatedInstanceService.ts index d517117da..e83b037dd 100644 --- a/packages/backend/src/core/FederatedInstanceService.ts +++ b/packages/backend/src/core/FederatedInstanceService.ts @@ -34,7 +34,7 @@ export class FederatedInstanceService { const i = await this.instancesRepository.insert({ id: this.idService.genId(), host, - caughtAt: new Date(), + firstRetrievedAt: new Date(), }).then(x => this.instancesRepository.findOneByOrFail(x.identifiers[0])); this.cache.set(host, i); diff --git a/packages/backend/src/core/entities/InstanceEntityService.ts b/packages/backend/src/core/entities/InstanceEntityService.ts index c8bb74deb..42ea5e23f 100644 --- a/packages/backend/src/core/entities/InstanceEntityService.ts +++ b/packages/backend/src/core/entities/InstanceEntityService.ts @@ -29,7 +29,7 @@ export class InstanceEntityService { const meta = await this.metaService.fetch(); return { id: instance.id, - caughtAt: instance.caughtAt.toISOString(), + firstRetrievedAt: instance.firstRetrievedAt.toISOString(), host: instance.host, usersCount: instance.usersCount, notesCount: instance.notesCount, diff --git a/packages/backend/src/models/entities/Instance.ts b/packages/backend/src/models/entities/Instance.ts index 8092f67c8..09328b57f 100644 --- a/packages/backend/src/models/entities/Instance.ts +++ b/packages/backend/src/models/entities/Instance.ts @@ -13,7 +13,7 @@ export class Instance { @Column('timestamp with time zone', { comment: 'The caught date of the Instance.', }) - public caughtAt: Date; + public firstRetrievedAt: Date; /** * ホスト diff --git a/packages/backend/src/models/schema/federation-instance.ts b/packages/backend/src/models/schema/federation-instance.ts index f3f93f309..42d93dfac 100644 --- a/packages/backend/src/models/schema/federation-instance.ts +++ b/packages/backend/src/models/schema/federation-instance.ts @@ -6,7 +6,7 @@ export const packedFederationInstanceSchema = { optional: false, nullable: false, format: 'id', }, - caughtAt: { + firstRetrievedAt: { type: 'string', optional: false, nullable: false, format: 'date-time', diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index 4c19988eb..e5d1df001 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -63,8 +63,8 @@ export default class extends Endpoint { case '-following': query.orderBy('instance.followingCount', 'ASC'); break; case '+followers': query.orderBy('instance.followersCount', 'DESC'); break; case '-followers': query.orderBy('instance.followersCount', 'ASC'); break; - case '+caughtAt': query.orderBy('instance.caughtAt', 'DESC'); break; - case '-caughtAt': query.orderBy('instance.caughtAt', 'ASC'); break; + case '+firstRetrievedAt': query.orderBy('instance.firstRetrievedAt', 'DESC'); break; + case '-firstRetrievedAt': query.orderBy('instance.firstRetrievedAt', 'ASC'); break; case '+latestRequestReceivedAt': query.orderBy('instance.latestRequestReceivedAt', 'DESC', 'NULLS LAST'); break; case '-latestRequestReceivedAt': query.orderBy('instance.latestRequestReceivedAt', 'ASC', 'NULLS FIRST'); break; diff --git a/packages/frontend/src/pages/about.federation.vue b/packages/frontend/src/pages/about.federation.vue index 101ea2297..90d6893f3 100644 --- a/packages/frontend/src/pages/about.federation.vue +++ b/packages/frontend/src/pages/about.federation.vue @@ -28,8 +28,8 @@ - - + + diff --git a/packages/frontend/src/pages/admin/federation.vue b/packages/frontend/src/pages/admin/federation.vue index 96bd087e6..f2c114ca2 100644 --- a/packages/frontend/src/pages/admin/federation.vue +++ b/packages/frontend/src/pages/admin/federation.vue @@ -32,8 +32,8 @@ - - + + diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 7607088eb..714f95add 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -38,7 +38,7 @@ - +