Compare commits
2 Commits
75fd042d74
...
2045ccebb5
| Author | SHA1 | Date | |
|---|---|---|---|
| 2045ccebb5 | |||
| efb4c8384d |
@@ -10,4 +10,4 @@ COPY . .
|
||||
|
||||
EXPOSE 5173
|
||||
|
||||
CMD ["npm", "run", "dev", "--", "--host"]
|
||||
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
||||
@@ -99,37 +99,27 @@ const InteractionalStats = ({ data }: InteractionalStatsProps) => {
|
||||
<div style={{ ...styles.card, gridColumn: "span 12" }}>
|
||||
<h2 style={styles.sectionTitle}>Conversation Overview</h2>
|
||||
<p style={styles.sectionSubtitle}>
|
||||
Who talks to who, and how concentrated the replies are.
|
||||
Who talks to who, how much they interact, and how concentrated the replies are.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Card
|
||||
label="Average Reply Depth"
|
||||
value={
|
||||
typeof data.average_thread_depth === "number"
|
||||
? data.average_thread_depth.toFixed(2)
|
||||
: "—"
|
||||
}
|
||||
sublabel="How deep reply chains usually go"
|
||||
style={{ gridColumn: "span 3" }}
|
||||
/>
|
||||
<Card
|
||||
label="Users in Network"
|
||||
value={userCount.toLocaleString()}
|
||||
sublabel="Users in the reply graph"
|
||||
style={{ gridColumn: "span 3" }}
|
||||
style={{ gridColumn: "span 4" }}
|
||||
/>
|
||||
<Card
|
||||
label="User-to-User Links"
|
||||
value={edgeCount.toLocaleString()}
|
||||
sublabel="Unique reply directions"
|
||||
style={{ gridColumn: "span 3" }}
|
||||
style={{ gridColumn: "span 4" }}
|
||||
/>
|
||||
<Card
|
||||
label="Total Replies"
|
||||
value={interactionVolume.toLocaleString()}
|
||||
sublabel="All reply links combined"
|
||||
style={{ gridColumn: "span 3" }}
|
||||
style={{ gridColumn: "span 4" }}
|
||||
/>
|
||||
<Card
|
||||
label="Concentrated Replies"
|
||||
|
||||
@@ -135,7 +135,6 @@ type ConversationConcentration = {
|
||||
};
|
||||
|
||||
type InteractionAnalysisResponse = {
|
||||
average_thread_depth?: number;
|
||||
top_interaction_pairs?: [[string, string], number][];
|
||||
conversation_concentration?: ConversationConcentration;
|
||||
interaction_graph: InteractionGraph;
|
||||
|
||||
@@ -31,28 +31,6 @@ class InteractionAnalysis:
|
||||
|
||||
return interactions
|
||||
|
||||
def average_thread_depth(self, df: pd.DataFrame):
|
||||
depths = []
|
||||
id_to_reply = df.set_index("id")["reply_to"].to_dict()
|
||||
for _, row in df.iterrows():
|
||||
depth = 0
|
||||
current_id = row["id"]
|
||||
|
||||
while True:
|
||||
reply_to = id_to_reply.get(current_id)
|
||||
if pd.isna(reply_to) or reply_to == "":
|
||||
break
|
||||
|
||||
depth += 1
|
||||
current_id = reply_to
|
||||
|
||||
depths.append(depth)
|
||||
|
||||
if not depths:
|
||||
return 0
|
||||
|
||||
return round(sum(depths) / len(depths), 2)
|
||||
|
||||
def top_interaction_pairs(self, df: pd.DataFrame, top_n=10):
|
||||
graph = self.interaction_graph(df)
|
||||
pairs = []
|
||||
|
||||
@@ -119,7 +119,6 @@ class StatGen:
|
||||
filtered_df = self._prepare_filtered_df(df, filters)
|
||||
|
||||
return {
|
||||
"average_thread_depth": self.interaction_analysis.average_thread_depth(filtered_df),
|
||||
"top_interaction_pairs": self.interaction_analysis.top_interaction_pairs(filtered_df, top_n=100),
|
||||
"interaction_graph": self.interaction_analysis.interaction_graph(filtered_df),
|
||||
"conversation_concentration": self.interaction_analysis.conversation_concentration(filtered_df)
|
||||
|
||||
Reference in New Issue
Block a user