mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
fix: [tracker] global tracker list: fix first/last seen
This commit is contained in:
parent
fb73c25675
commit
57a69fa1f4
4 changed files with 14 additions and 20 deletions
|
@ -288,6 +288,8 @@ def fix_tracker_stats_per_day(tracker_uuid):
|
||||||
date_to = Date.get_today_date_str()
|
date_to = Date.get_today_date_str()
|
||||||
# delete stats
|
# delete stats
|
||||||
r_serv_tracker.delete(f'tracker:stat:{tracker_uuid}')
|
r_serv_tracker.delete(f'tracker:stat:{tracker_uuid}')
|
||||||
|
r_serv_tracker.hdel(f'tracker:{tracker_uuid}', 'first_seen')
|
||||||
|
r_serv_tracker.hdel(f'tracker:{tracker_uuid}', 'last_seen')
|
||||||
# create new stats
|
# create new stats
|
||||||
for date_day in Date.substract_date(date_from, date_to):
|
for date_day in Date.substract_date(date_from, date_to):
|
||||||
date_day = int(date_day)
|
date_day = int(date_day)
|
||||||
|
@ -303,6 +305,7 @@ def fix_tracker_item_link(tracker_uuid):
|
||||||
date_from = get_tracker_first_seen(tracker_uuid)
|
date_from = get_tracker_first_seen(tracker_uuid)
|
||||||
date_to = get_tracker_last_seen(tracker_uuid)
|
date_to = get_tracker_last_seen(tracker_uuid)
|
||||||
|
|
||||||
|
if date_from and date_to:
|
||||||
for date_day in Date.substract_date(date_from, date_to):
|
for date_day in Date.substract_date(date_from, date_to):
|
||||||
l_items = r_serv_tracker.smembers(f'tracker:item:{tracker_uuid}:{date_day}')
|
l_items = r_serv_tracker.smembers(f'tracker:item:{tracker_uuid}:{date_day}')
|
||||||
for item_id in l_items:
|
for item_id in l_items:
|
||||||
|
@ -310,8 +313,8 @@ def fix_tracker_item_link(tracker_uuid):
|
||||||
|
|
||||||
def fix_all_tracker_uuid_list():
|
def fix_all_tracker_uuid_list():
|
||||||
r_serv_tracker.delete(f'trackers:all')
|
r_serv_tracker.delete(f'trackers:all')
|
||||||
r_serv_tracker.delete(f'trackers:all:{tracker_type}')
|
|
||||||
for tracker_type in get_all_tracker_type():
|
for tracker_type in get_all_tracker_type():
|
||||||
|
r_serv_tracker.delete(f'trackers:all:{tracker_type}')
|
||||||
l_tracker = get_all_tracker_by_type(tracker_type)
|
l_tracker = get_all_tracker_by_type(tracker_type)
|
||||||
for tracker in l_tracker:
|
for tracker in l_tracker:
|
||||||
l_tracker_uuid = get_tracker_uuid_list(tracker, tracker_type)
|
l_tracker_uuid = get_tracker_uuid_list(tracker, tracker_type)
|
||||||
|
|
|
@ -431,19 +431,10 @@ def parse_get_tracker_term_item(dict_input, user_id):
|
||||||
return (res_dict, 200)
|
return (res_dict, 200)
|
||||||
|
|
||||||
def get_tracked_term_first_seen(term_uuid):
|
def get_tracked_term_first_seen(term_uuid):
|
||||||
res = r_serv_term.zrange('tracker:stat:{}'.format(term_uuid), 0, 0)
|
return Tracker.get_tracker_first_seen(term_uuid)
|
||||||
if res:
|
|
||||||
return res[0]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_tracked_term_last_seen(term_uuid):
|
def get_tracked_term_last_seen(term_uuid):
|
||||||
res = r_serv_term.zrevrange('tracker:stat:{}'.format(term_uuid), 0, 0)
|
return Tracker.get_tracker_last_seen(term_uuid)
|
||||||
if res:
|
|
||||||
return res[0]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_term_metedata(term_uuid, user_id=False, description=False, level=False, tags=False, mails=False, sparkline=False):
|
def get_term_metedata(term_uuid, user_id=False, description=False, level=False, tags=False, mails=False, sparkline=False):
|
||||||
dict_uuid = {}
|
dict_uuid = {}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Updater(AIL_Updater):
|
||||||
print('Fixing Tracker_uuid list ...')
|
print('Fixing Tracker_uuid list ...')
|
||||||
Tracker.fix_all_tracker_uuid_list()
|
Tracker.fix_all_tracker_uuid_list()
|
||||||
nb = 0
|
nb = 0
|
||||||
for tracker_uuid in get_all_tracker_uuid:
|
for tracker_uuid in Tracker.get_all_tracker_uuid():
|
||||||
self.r_serv.sadd('trackers_update_v3.7', tracker_uuid)
|
self.r_serv.sadd('trackers_update_v3.7', tracker_uuid)
|
||||||
nb += 1
|
nb += 1
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ if __name__ == '__main__':
|
||||||
nb_elem_to_update = int(nb_elem_to_update)
|
nb_elem_to_update = int(nb_elem_to_update)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
tracker_uuid = r_serv_onion.spop('trackers_update_v3.7')
|
tracker_uuid = r_serv_db.spop('trackers_update_v3.7')
|
||||||
if tracker_uuid is not None:
|
if tracker_uuid is not None:
|
||||||
print(tracker_uuid)
|
print(tracker_uuid)
|
||||||
# FIX STATS
|
# FIX STATS
|
||||||
|
|
Loading…
Reference in a new issue