Skip to content

Commit

Permalink
chore: fix timestamps in community helps
Browse files Browse the repository at this point in the history
  • Loading branch information
JessChowdhury committed Jan 29, 2025
1 parent 5903166 commit 093877a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/scripts/fetchDiscord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,17 @@ function processMessages(messages: Message[]) {

function createSanitizedThread(thread: Thread, messages: Message[]) {
const [intro, ...combinedResponses] = processMessages(messages)
const createdAtDate = intro
? new Date(intro.timestamp).toISOString()
: new Date(thread.thread_metadata.create_timestamp).toISOString()

return {
slug: sanitizeSlug(thread.name),
info: {
id: thread.id,
name: thread.name,
archived: thread.thread_metadata.archived,
createdAt: thread.thread_metadata.create_timestamp,
createdAt: createdAtDate,
guildId: thread.guild_id,
},
intro: intro
Expand Down
6 changes: 4 additions & 2 deletions src/scripts/syncToAlgolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ export const syncToAlgolia = async (): Promise<void> => {
const githubDocs: GithubDoc[] = []

docs.forEach((doc) => {
const { communityHelpJSON, discordID, githubID, helpful } = doc
const { communityHelpJSON, discordID, githubID, helpful, threadCreatedAt } = doc

if (discordID) {
const { slug, info, intro, messageCount, messages } = communityHelpJSON
const formattedDate = threadCreatedAt || info.createdAt

discordDocs.push({
name: info.name,
slug,
author: intro.authorName,
createdAt: info.createdAt,
createdAt: formattedDate,
helpful: helpful ?? false,
messageCount,
messages: messages.map((message) => {
Expand Down

0 comments on commit 093877a

Please sign in to comment.