wip
This commit is contained in:
17
posthist.py
17
posthist.py
@@ -28,8 +28,8 @@ def main(folder):
|
||||
print((option_date_from.strftime("%d-%m-%Y"), option_date_to.strftime("%d-%m-%Y")))
|
||||
|
||||
# filter posts by option_date_from <= creation date <= option_date_to
|
||||
newusers = set(dmt(users).filter(lambda u: option_date_from <= u['CreationDate'] < option_date_to, "filtering users by creation").map(lambda u: u['Id'], "getting user ids").getresults())
|
||||
newposts = dmt(posts).filter(lambda p: p['OwnerUserId'] in newusers, "filtering posts by users").getresults()
|
||||
# newusers = set(dmt(users).filter(lambda u: option_date_from <= u['CreationDate'] < option_date_to, "filtering users by creation").map(lambda u: u['Id'], "getting user ids").getresults())
|
||||
newposts = dmt(posts).filter(lambda p: option_date_from <= p['CreationDate'] < option_date_to, "filtering posts by date").getresults()
|
||||
|
||||
postcounts = defaultdict(list)
|
||||
i = 0
|
||||
@@ -39,16 +39,9 @@ def main(folder):
|
||||
postcounts = {id: len(pc) for (id, pc) in postcounts.items()}
|
||||
# print("i: " + str(i) + " expected: " + str(len(newposts)) + " is: " + str(sum([pc for pc in postcounts.values()])))
|
||||
|
||||
os.system("mkdir -p " + folder + "/output")
|
||||
histfilename = folder + "/output/posthist_" + folder.split("/")[-1] + "_" + option_date_from.strftime("%d-%m-%Y") + "_" + option_date_to.strftime("%d-%m-%Y")
|
||||
countfilename = folder + "/output/postcount_" + folder.split("/")[-1] + "_" + option_date_from.strftime("%d-%m-%Y") + "_" + option_date_to.strftime("%d-%m-%Y")
|
||||
|
||||
# fig = plt.figure(figsize=(16, 12))
|
||||
# plt.plot(userids, [len(pc) for pc in postcounts])
|
||||
# plt.title("Post count for users between " + option_date_from.strftime("%d-%m-%Y") + " and " + option_date_to.strftime("%d-%m-%Y"))
|
||||
# plt.xticks(rotation=90)
|
||||
# fig.savefig(countfilename + ".png", bbox_inches='tight')
|
||||
# plt.close(fig)
|
||||
outputdir = folder + "/output/posthist/"
|
||||
os.system("mkdir -p " + outputdir)
|
||||
histfilename = outputdir + "posthist_" + folder.split("/")[-1] + "_" + option_date_from.strftime("%d-%m-%Y") + "_" + option_date_to.strftime("%d-%m-%Y")
|
||||
|
||||
histdata = [pc for pc in postcounts.values()]
|
||||
fig = plt.figure(figsize=(16, 12))
|
||||
|
||||
Reference in New Issue
Block a user