-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show most active participants and groups, word cloud in Ended S…
…tage (#91) * feat: show most active participants and groups in Ended Stage * feat: show word cloud in Ended Stage
- Loading branch information
1 parent
5b119a5
commit cf58cb2
Showing
5 changed files
with
133 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/routes/api/session/[id]/conversations/keywords/+server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { getGroupsData, getGroupsRef } from '$lib/utils/firestore'; | ||
import { error, json } from '@sveltejs/kit'; | ||
import type { RequestHandler } from './$types'; | ||
|
||
export const GET: RequestHandler = async ({ params }) => { | ||
try { | ||
const groupsRef = getGroupsRef(params.id); | ||
const groups = await getGroupsData(groupsRef); | ||
|
||
// 建立關鍵字頻率統計 | ||
const keywordFrequency: Record<string, number> = {}; | ||
|
||
// 遍歷所有群組的關鍵字 | ||
groups.forEach((group) => { | ||
if (group.keywords) { | ||
Object.entries(group.keywords).forEach(([, count]) => { | ||
keywordFrequency[count] = (keywordFrequency[count] || 0) + 1; | ||
}); | ||
} | ||
}); | ||
|
||
return json(keywordFrequency); | ||
} catch (err) { | ||
console.error('Error fetching data:', err); | ||
throw error(500, '無法獲取資料'); | ||
} | ||
}; |
13 changes: 13 additions & 0 deletions
13
src/routes/api/session/[id]/conversations/most-active-participants/+server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { getConversationsFromAllParticipantsData } from '$lib/utils/firestore'; | ||
import { error, json } from '@sveltejs/kit'; | ||
import type { RequestHandler } from './$types'; | ||
|
||
export const GET: RequestHandler = async ({ params }) => { | ||
try { | ||
const conversations = await getConversationsFromAllParticipantsData(params.id); | ||
return json(conversations); | ||
} catch (err) { | ||
console.error('Error fetching data:', err); | ||
throw error(500, '無法獲取資料'); | ||
} | ||
}; |