fix: [terms tracker] refresh Tracked terms

This commit is contained in:
Terrtia 2021-04-02 16:54:45 +02:00
parent b6da063473
commit 24ef8bb461
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -60,6 +60,17 @@ class TermTrackerMod(AbstractModule):
def compute(self, item_id): def compute(self, item_id):
# refresh Tracked term
if self.last_refresh_word < Term.get_tracked_term_last_updated_by_type('word'):
self.list_tracked_words = Term.get_tracked_words_list()
self.last_refresh_word = time.time()
self.redis_logger.debug('Tracked word refreshed')
if self.last_refresh_set < Term.get_tracked_term_last_updated_by_type('set'):
self.set_tracked_words_list = Term.get_set_tracked_words_list()
self.last_refresh_set = time.time()
self.redis_logger.debug('Tracked set refreshed')
# Cast message as Item # Cast message as Item
item_date = Item.get_item_date(item_id) item_date = Item.get_item_date(item_id)
item_content = Item.get_item_content(item_id) item_content = Item.get_item_content(item_id)
@ -97,18 +108,6 @@ class TermTrackerMod(AbstractModule):
if nb_uniq_word >= nb_words_threshold: if nb_uniq_word >= nb_words_threshold:
self.new_term_found(word_set, 'set', item_id, item_date) self.new_term_found(word_set, 'set', item_id, item_date)
# refresh Tracked term
if self.last_refresh_word < Term.get_tracked_term_last_updated_by_type('word'):
self.list_tracked_words = Term.get_tracked_words_list()
self.last_refresh_word = time.time()
self.redis_logger.debug('Tracked word refreshed')
if self.last_refresh_set < Term.get_tracked_term_last_updated_by_type('set'):
self.set_tracked_words_list = Term.get_set_tracked_words_list()
self.last_refresh_set = time.time()
self.redis_logger.debug('Tracked set refreshed')
def new_term_found(self, term, term_type, item_id, item_date): def new_term_found(self, term, term_type, item_id, item_date):
uuid_list = Term.get_term_uuid_list(term, term_type) uuid_list = Term.get_term_uuid_list(term, term_type)
self.redis_logger.info('new tracked term found: {} in {}'.format(term, item_id)) self.redis_logger.info('new tracked term found: {} in {}'.format(term, item_id))