Skip to content

Commit fe3930e

Browse files
committed
chore: fix timestamps in community helps
1 parent 5903166 commit fe3930e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/scripts/fetchDiscord.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,17 @@ function processMessages(messages: Message[]) {
140140

141141
function createSanitizedThread(thread: Thread, messages: Message[]) {
142142
const [intro, ...combinedResponses] = processMessages(messages)
143+
const createdAtDate = intro
144+
? new Date(intro.timestamp)
145+
: new Date(thread.thread_metadata.create_timestamp).toISOString()
143146

144147
return {
145148
slug: sanitizeSlug(thread.name),
146149
info: {
147150
id: thread.id,
148151
name: thread.name,
149152
archived: thread.thread_metadata.archived,
150-
createdAt: thread.thread_metadata.create_timestamp,
153+
createdAt: createdAtDate,
151154
guildId: thread.guild_id,
152155
},
153156
intro: intro

src/scripts/syncToAlgolia.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,17 @@ export const syncToAlgolia = async (): Promise<void> => {
5555
const githubDocs: GithubDoc[] = []
5656

5757
docs.forEach((doc) => {
58-
const { communityHelpJSON, discordID, githubID, helpful } = doc
58+
const { communityHelpJSON, discordID, githubID, helpful, threadCreatedAt } = doc
5959

6060
if (discordID) {
6161
const { slug, info, intro, messageCount, messages } = communityHelpJSON
62+
const formattedDate = threadCreatedAt || new Date(info.createdAt).toISOString()
63+
6264
discordDocs.push({
6365
name: info.name,
6466
slug,
6567
author: intro.authorName,
66-
createdAt: info.createdAt,
68+
createdAt: formattedDate,
6769
helpful: helpful ?? false,
6870
messageCount,
6971
messages: messages.map((message) => {

0 commit comments

Comments
 (0)