Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
fix #106 メッセージのデプロイ対象・削除対象の取得がずれる問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
yogarasu committed Oct 4, 2022
1 parent a9ea67e commit 91915a4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions libs/message.mts
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,18 @@ export class MessageClient {
throw new Error(`Failed to get channel manager of ${channel.id}`)

// Pagination message
const take = 100
let skip = 0
const total = await this.client.message.count({
where: {
// Get only undeployed message for redeploy
deployId: { equals: null },
channelDeployId: channel.deployId,
},
})
while (skip < total) {

const take = 100
for (let skip = 0; skip < total; skip += take) {
const messages = await this.client.message.findMany({
take: take,
skip: skip,
where: {
deployId: { equals: null },
channelDeployId: channel.deployId,
Expand All @@ -203,7 +202,6 @@ export class MessageClient {
})

await this.deployManyMessage(channelManager, fileChannelManager, messages)
skip += take
}
}
}
Expand Down Expand Up @@ -361,26 +359,25 @@ export class MessageClient {
throw new Error(`Failed to get channel manager of ${channel.id}`)

// Pagination message
const take = 100
let skip = 0
const total = await this.client.message.count({
where: {
channelDeployId: channel.deployId,
},
})
while (skip < total) {

const take = 100
for (let skip = 0; skip < total; skip += take) {
const messages = await this.client.message.findMany({
take: take,
skip: skip,
where: {
NOT: { deployId: { equals: null } },
channelDeployId: channel.deployId,
},
orderBy: {
timestamp: 'asc',
},
})
await this.destroyManyMessage(channelManager, messages)
skip += take
}
})
)
Expand Down

0 comments on commit 91915a4

Please sign in to comment.