wip
This commit is contained in:
11
posthist.py
11
posthist.py
@@ -43,10 +43,11 @@ def main(folder, intervl):
|
||||
postcounts = {id: len(pc) for (id, pc) in postcounts.items()}
|
||||
activeusercounts.append(((option_date_from, option_date_to), len(postcounts.keys())))
|
||||
|
||||
activitynewusersinmonth = defaultdict(int) # TODO match month exactly
|
||||
activitynewusersinmonth = defaultdict(int)
|
||||
for p in newposts:
|
||||
if firstcontrib[p['OwnerUserId']] + timedelta(days=DAYS_NEW_USER) > p['CreationDate']:
|
||||
activitynewusersinmonth[p['OwnerUserId']] += 1
|
||||
for p in posts:
|
||||
for a in p['Answers']:
|
||||
if firstcontrib[a['OwnerUserId']] + timedelta(days=DAYS_NEW_USER) > a['CreationDate']:
|
||||
activitynewusersinmonth[p['OwnerUserId']] += 1
|
||||
@@ -63,14 +64,16 @@ def main(folder, intervl):
|
||||
plt.xlabel("#posts")
|
||||
plt.ylabel("#users with X posts")
|
||||
fig.gca().xaxis.set_major_locator(MaxNLocator(integer=True))
|
||||
plt.title("Histogram for user post count registered between " + option_date_from.strftime("%d-%m-%Y") + " and " + option_date_to.strftime("%d-%m-%Y"))
|
||||
plt.title("Histogram for user post count between " + option_date_from.strftime("%d-%m-%Y") + " and " + option_date_to.strftime("%d-%m-%Y"))
|
||||
fig.savefig(histfilename + ".png", bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
imgmagickcmd += " " + histfilename + ".png"
|
||||
|
||||
# answers to new users
|
||||
answers = (dmt(posts).map(lambda q: [a for a in q['Answers'] if option_date_from <= a['CreationDate'] < option_date_to
|
||||
and firstcontrib[q['OwnerUserId']] + timedelta(days=DAYS_NEW_USER) <= a['CreationDate']])
|
||||
answers = (dmt(posts).map(lambda q: [a for a in q['Answers']
|
||||
if option_date_from <= a['CreationDate'] < option_date_to # answer in interval
|
||||
and firstcontrib[q['OwnerUserId']] + timedelta(days=DAYS_NEW_USER) > q['CreationDate'] # post created within 1 week of 1st contrib
|
||||
and q['CreationDate'] + timedelta(days=DAYS_NEW_USER) > a['CreationDate']]) # answer created within 1 week of post
|
||||
.getresults())
|
||||
count = sum([len(a) for a in answers])
|
||||
answerstonewusers.append(((option_date_from, option_date_to), count))
|
||||
|
||||
Reference in New Issue
Block a user