mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-14 10:38:22 +00:00
fix: [tag] tag delete: fix update first/last seen
This commit is contained in:
parent
12c5483467
commit
faea17572c
1 changed files with 22 additions and 13 deletions
|
@ -625,20 +625,29 @@ def _update_tag_first_seen(tag, first_seen, last_seen):
|
||||||
|
|
||||||
# # TODO:
|
# # TODO:
|
||||||
def _update_tag_last_seen(tag, first_seen, last_seen):
|
def _update_tag_last_seen(tag, first_seen, last_seen):
|
||||||
if first_seen == last_seen:
|
update = True
|
||||||
if r_tags.scard(f'item::{tag}:{last_seen}') > 0:
|
while update:
|
||||||
r_tags.hset(f'tag_metadata:{tag}', 'last_seen', last_seen)
|
if first_seen == last_seen:
|
||||||
# no tag in db
|
if r_tags.scard(f'item::{tag}:{last_seen}') > 0:
|
||||||
|
r_tags.hset(f'tag_metadata:{tag}', 'last_seen', last_seen)
|
||||||
|
update = False
|
||||||
|
break
|
||||||
|
# no tag in db
|
||||||
|
else:
|
||||||
|
r_tags.hdel(f'tag_metadata:{tag}', 'first_seen')
|
||||||
|
r_tags.hdel(f'tag_metadata:{tag}', 'last_seen')
|
||||||
|
update = False
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
r_tags.hdel(f'tag_metadata:{tag}', 'first_seen')
|
if r_tags.scard(f'item::{tag}:{last_seen}') > 0:
|
||||||
r_tags.hdel(f'tag_metadata:{tag}', 'last_seen')
|
r_tags.hset(f'tag_metadata:{tag}', 'last_seen', last_seen)
|
||||||
else:
|
update = False
|
||||||
if r_tags.scard(f'item::{tag}:{last_seen}') > 0:
|
break
|
||||||
r_tags.hset(f'tag_metadata:{tag}', 'last_seen', last_seen)
|
else:
|
||||||
else:
|
last_seen = Date.date_substract_day(str(last_seen))
|
||||||
last_seen = Date.date_substract_day(str(last_seen))
|
if int(last_seen) < int(first_seen):
|
||||||
if int(last_seen) >= int(first_seen):
|
update = False
|
||||||
_update_tag_last_seen(tag, first_seen, last_seen)
|
break
|
||||||
|
|
||||||
|
|
||||||
def update_tag_metadata(tag, date, delete=False): # # TODO: delete Tags
|
def update_tag_metadata(tag, date, delete=False): # # TODO: delete Tags
|
||||||
|
|
Loading…
Reference in a new issue