Created
June 17, 2016 14:17
-
-
Save h0rn3t/902f5e506f938c3ca8722cbae169d9bd to your computer and use it in GitHub Desktop.
stat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# coding: utf-8 | |
from db import db | |
import time | |
import calendar | |
month = 43200*60 | |
day = 24*60*60 | |
week = 24*60*60*7 | |
curent_timestamp = int(time.time()) | |
last_month = curent_timestamp - month | |
last_day = curent_timestamp - day | |
last_week = curent_timestamp - week | |
users = list(db.users.find()) | |
month_activ_users = [] | |
week_activ_users = [] | |
points = list(db.points.find({})) | |
comments = list(db.points_comments.find({})) | |
last_month_points = [] | |
last_day_users = [] | |
for comment in comments: | |
for msg in comment['comments']: | |
if msg['time'] > last_week: | |
if str(msg['user_id']) not in week_activ_users: | |
week_activ_users.append(str(msg['user_id'])) | |
if msg['time'] > last_month: | |
if str(msg['user_id']) not in month_activ_users: | |
month_activ_users.append(str(msg['user_id'])) | |
for point in points: | |
point['created_time'] = int(calendar.timegm(point['_id'].generation_time.timetuple())) | |
if point['created_time'] > last_week: | |
if str(point['user_id']) not in week_activ_users: | |
week_activ_users.append(str(point['user_id'])) | |
if point['created_time'] > last_week: | |
if str(point['user_id']) not in month_activ_users: | |
month_activ_users.append(str(point['user_id'])) | |
""" | |
for user in users: | |
user['created_time'] = int(calendar.timegm(user['_id'].generation_time.timetuple())) | |
if user['created_time'] > last_day: | |
last_day_users.append(user) | |
print('last_week points', len(last_month_points)) | |
print('last 24 hour users: ', len(last_day_users)) | |
print('active users: ', len(activ_users)) | |
""" | |
print('month_activ_users: ', len(month_activ_users)) | |
print('week_activ_users: ', len(week_activ_users)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment