refactor: move api types into dedicated file
This commit is contained in:
@@ -15,30 +15,7 @@ import { ReactWordcloud } from '@cp949/react-wordcloud';
|
|||||||
import StatsStyling from "../styles/stats_styling";
|
import StatsStyling from "../styles/stats_styling";
|
||||||
import Card from "../components/Card";
|
import Card from "../components/Card";
|
||||||
|
|
||||||
type BackendWord = {
|
import type { TopUser, SummaryResponse, FrequencyWord } from '../types/ApiTypes'
|
||||||
word: string;
|
|
||||||
count: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
type TopUser = {
|
|
||||||
author: string;
|
|
||||||
source: string;
|
|
||||||
count: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
type SummaryResponse = {
|
|
||||||
total_events: number;
|
|
||||||
total_posts: number;
|
|
||||||
total_comments: number;
|
|
||||||
unique_users: number;
|
|
||||||
comments_per_post: number;
|
|
||||||
lurker_ratio: number;
|
|
||||||
time_range: {
|
|
||||||
start: number;
|
|
||||||
end: number;
|
|
||||||
};
|
|
||||||
sources: string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
const styles = StatsStyling;
|
const styles = StatsStyling;
|
||||||
|
|
||||||
@@ -105,7 +82,7 @@ const StatPage = () => {
|
|||||||
setTopUserData(topUsers);
|
setTopUserData(topUsers);
|
||||||
setHeatmapData(weekdayHourHeatmap);
|
setHeatmapData(weekdayHourHeatmap);
|
||||||
setWordFrequencyData(
|
setWordFrequencyData(
|
||||||
wordFrequencies.map((d: BackendWord) => ({
|
wordFrequencies.map((d: FrequencyWord) => ({
|
||||||
text: d.word,
|
text: d.word,
|
||||||
value: d.count,
|
value: d.count,
|
||||||
}))
|
}))
|
||||||
|
|||||||
59
frontend/src/types/ApiTypes.ts
Normal file
59
frontend/src/types/ApiTypes.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
// User Code
|
||||||
|
type TopUser = {
|
||||||
|
author: string;
|
||||||
|
source: string;
|
||||||
|
count: number
|
||||||
|
};
|
||||||
|
|
||||||
|
type Vocab = {
|
||||||
|
author: string;
|
||||||
|
events: number;
|
||||||
|
total_words: number;
|
||||||
|
unique_words: number;
|
||||||
|
vocab_richness: number;
|
||||||
|
avg_words_per_event: number;
|
||||||
|
top_words: { word: string; count: number }[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type User = {
|
||||||
|
author: string;
|
||||||
|
post: number;
|
||||||
|
comment: number;
|
||||||
|
comment_post_ratio: number;
|
||||||
|
comment_share: number;
|
||||||
|
vocab?: Vocab | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
type UserAnalysisResponse = {
|
||||||
|
top_users: TopUser[];
|
||||||
|
users: User[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type FrequencyWord = {
|
||||||
|
word: string;
|
||||||
|
count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Summary
|
||||||
|
type SummaryResponse = {
|
||||||
|
total_events: number;
|
||||||
|
total_posts: number;
|
||||||
|
total_comments: number;
|
||||||
|
unique_users: number;
|
||||||
|
comments_per_post: number;
|
||||||
|
lurker_ratio: number;
|
||||||
|
time_range: {
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
};
|
||||||
|
sources: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type {
|
||||||
|
TopUser,
|
||||||
|
Vocab,
|
||||||
|
User,
|
||||||
|
UserAnalysisResponse,
|
||||||
|
FrequencyWord,
|
||||||
|
SummaryResponse
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user