mirror of
https://github.com/norohind/jubilant-system.git
synced 2025-06-10 20:02:04 +03:00
Add back scan on discover
This commit is contained in:
parent
7545514269
commit
62befc58b7
15
main.py
15
main.py
@ -75,9 +75,9 @@ def shutdown_callback(sig, frame) -> None:
|
|||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
def discover():
|
def discover(back_count: int = 0):
|
||||||
"""Discover new squads
|
"""Discover new squads
|
||||||
|
:param back_count: int how many squads back we should check, it is helpful to recheck newly created squads
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -104,6 +104,15 @@ def discover():
|
|||||||
*Outdated but it still can be more smart*
|
*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:
|
while True:
|
||||||
|
|
||||||
if shutting_down:
|
if shutting_down:
|
||||||
@ -208,7 +217,7 @@ if __name__ == '__main__':
|
|||||||
can_be_shutdown = False
|
can_be_shutdown = False
|
||||||
logger.info('Discovering')
|
logger.info('Discovering')
|
||||||
|
|
||||||
discover()
|
discover(back_count=20)
|
||||||
if shutting_down:
|
if shutting_down:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
@ -72,6 +72,11 @@ from squads_view
|
|||||||
order by inserted_timestamp asc
|
order by inserted_timestamp asc
|
||||||
limit ?;"""
|
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
|
select_first_hole_id: str = """select squad_id+1 as a
|
||||||
from squads_states except
|
from squads_states except
|
||||||
select squad_id
|
select squad_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user