mirror of
https://github.com/Tech-Workers-Coalition-Italia/mobilizon-reshare.git
synced 2025-02-11 09:10:51 +01:00
main: Use get_published_events query.
This commit is contained in:
parent
c129edd1e5
commit
dd664089d8
@ -5,6 +5,7 @@ from tortoise import run_async
|
|||||||
|
|
||||||
from mobilizon_bots.config.config import settings
|
from mobilizon_bots.config.config import settings
|
||||||
from mobilizon_bots.storage.db import MobilizonBotsDB
|
from mobilizon_bots.storage.db import MobilizonBotsDB
|
||||||
|
from mobilizon_bots.storage.query import get_published_events
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ async def main():
|
|||||||
logging.config.dictConfig(settings.logging)
|
logging.config.dictConfig(settings.logging)
|
||||||
db = MobilizonBotsDB(Path(settings.db_path))
|
db = MobilizonBotsDB(Path(settings.db_path))
|
||||||
await db.setup()
|
await db.setup()
|
||||||
published_events = db.get_published_events()
|
published_events = get_published_events()
|
||||||
unpublished_events = get_unpublished_events(published_events)
|
unpublished_events = get_unpublished_events(published_events)
|
||||||
event = select_event_to_publish()
|
event = select_event_to_publish()
|
||||||
result = PublisherCoordinator(event).publish() if event else exit(0)
|
result = PublisherCoordinator(event).publish() if event else exit(0)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import asyncio
|
||||||
|
import atexit
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -34,3 +36,10 @@ class MobilizonBotsDB:
|
|||||||
await Tortoise.generate_schemas()
|
await Tortoise.generate_schemas()
|
||||||
self.is_init = True
|
self.is_init = True
|
||||||
logger.info(f"Succesfully initialized database at {self.path}")
|
logger.info(f"Succesfully initialized database at {self.path}")
|
||||||
|
|
||||||
|
|
||||||
|
@atexit.register
|
||||||
|
def gracefully_tear_down():
|
||||||
|
logger.info("Shutting down DB")
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.run_until_complete(Tortoise.close_connections())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user