Skip to content

Commit 46424a0

Browse files
OmarOmar
authored andcommitted
Updating the queries to filter the 'dead' and 'deleted' items
1 parent 8048ea2 commit 46424a0

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

analysis/core_analysis.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ def analyze_contributions_vs_score():
103103
view_of_interest_first = (
104104
df[
105105
(df["first_appearance"] < 2024) #& (~df["last_appearance"].isin([2023, 2024]))
106+
# ~(
107+
# (df["first_appearance"] == 2023) & (df["last_appearance"] == 2023)
108+
# ) # .any( axis=1)
109+
# & (df["last_appearance"] < 2024)
106110
] # Remove this year and last year, in order no to mix the findings.
107111
.groupby("first_appearance")
108112
.agg({"author_name": "count"})
@@ -114,6 +118,7 @@ def analyze_contributions_vs_score():
114118
view_of_interest = view_of_interest_first.merge(
115119
view_of_interest_last,
116120
how="outer",
121+
# how="inner",
117122
left_on="first_appearance",
118123
right_on="last_appearance",
119124
suffixes=("_first", "_last"),
@@ -140,7 +145,7 @@ def analyze_contributions_vs_score():
140145
fig.update_layout(font=font_settings)
141146
# Show all the xticks
142147
fig.update_xaxes(tickmode="linear")
143-
148+
144149
# Rename the y-axis legends
145150
newnames = {
146151
"new_users": "First-seen users",
@@ -246,7 +251,7 @@ def analyze_contributions_vs_score():
246251
# Center the title
247252
fig.update_layout(title_x=0.5)
248253
fig.update_layout(font=font_settings)
249-
# fig.show()
254+
fig.show()
250255
# Save the figure
251256
fig.write_image("nb_of_stories_vs_author_total_score.png")
252257

@@ -571,7 +576,7 @@ def analyze_contributions_vs_score_v2():
571576
df = AnyQueries(
572577
fresh=False,
573578
query_name="contributions_vs_karma_vs_score",
574-
# fresh=True, query_name="comments_per_year"
579+
# fresh=False, query_name="comments_per_year"
575580
).get_df()
576581
print(f"Time to get the data: {time.time() - time_start:.2f} seconds")
577582
print(df.shape)
@@ -601,7 +606,7 @@ def analyze_contributions_vs_score_v2():
601606
# Center the title
602607
fig.update_layout(title_x=0.5)
603608
fig.update_layout(font=font_settings)
604-
# fig.show()
609+
fig.show()
605610
# Save the figure
606611
fig.write_image("author_karma_vs_nb_of_stories.png")
607612

@@ -709,7 +714,7 @@ def main():
709714
analyze_contributions_vs_score()
710715
analyze_type_per_time()
711716
analyze_commentators_behavior()
712-
# analyze_contributions_vs_score_v2()
717+
analyze_contributions_vs_score_v2()
713718

714719
if __name__ == "__main__":
715720
main()

analysis/queries/commentators_behavior.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
},
88
'by': {
99
'$ne': None
10-
}
10+
},
11+
'dead': False,
12+
'deleted': False
1113
}
1214
}, {
1315
'$addFields': {

analysis/queries/comments_per_year.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
'type': 'comment',
55
'time': {
66
'$ne': None
7-
}
7+
},
8+
'dead': False,
9+
'deleted': False
810
}
911
},
1012
{

analysis/queries/contributions_vs_score.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
},
88
'by': {
99
'$ne': None
10-
}
10+
},
11+
'dead': False,
12+
'deleted': False
1113
}
1214
}, {
1315
'$addFields': {

analysis/queries/freq_of_type_per_time.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
'$match': {
44
'time': {
55
'$ne': None
6-
}
6+
},
7+
'dead': False,
8+
'deleted': False
79
}
810
}, {
911
'$addFields': {

analysis/queries/stories_per_year.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
'type': 'story',
55
'time': {
66
'$ne': None
7-
}
7+
},
8+
'dead': False,
9+
'deleted': False
810
}
911
}, {
1012
'$addFields': {

0 commit comments

Comments
 (0)