diff --git a/main.py b/main.py index 1319051..aba7b6b 100644 --- a/main.py +++ b/main.py @@ -75,9 +75,9 @@ def shutdown_callback(sig, frame) -> None: exit(0) -def discover(): +def discover(back_count: int = 0): """Discover new squads - + :param back_count: int how many squads back we should check, it is helpful to recheck newly created squads :return: """ @@ -104,6 +104,15 @@ def discover(): *Outdated but it still can be more smart* """ + if back_count != 0: + logger.debug(f'back_count = {back_count}') + + squad_id: list + for squad_id in db.execute(sql_requests.select_new_squads_to_update, (back_count,)).fetchall(): + squad_id: int = squad_id[0] + logger.debug(f'Back updating {squad_id}') + utils.update_squad_info(squad_id, db) + while True: if shutting_down: @@ -208,7 +217,7 @@ if __name__ == '__main__': can_be_shutdown = False logger.info('Discovering') - discover() + discover(back_count=20) if shutting_down: exit(0) diff --git a/sql_requests.py b/sql_requests.py index 16fb2d6..982d0c5 100644 --- a/sql_requests.py +++ b/sql_requests.py @@ -72,6 +72,11 @@ from squads_view order by inserted_timestamp asc limit ?;""" +select_new_squads_to_update: str = """select squad_id +from squads_view +order by squad_id desc +limit ?;""" + select_first_hole_id: str = """select squad_id+1 as a from squads_states except select squad_id