2022-03-22 21:16:34 +01:00
|
|
|
import logging.config
|
|
|
|
|
|
|
|
from mobilizon_reshare.event.event import MobilizonEvent
|
|
|
|
from mobilizon_reshare.mobilizon.events import get_mobilizon_future_events
|
2022-07-12 07:39:56 +02:00
|
|
|
from mobilizon_reshare.storage.query.write import create_unpublished_events
|
2022-03-22 21:16:34 +01:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
async def pull() -> list[MobilizonEvent]:
|
|
|
|
"""
|
|
|
|
Fetches the latest events from Mobilizon and stores them.
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Pull future events from Mobilizon
|
|
|
|
future_events = get_mobilizon_future_events()
|
|
|
|
logger.info(f"Pulled {len(future_events)} events from Mobilizon.")
|
|
|
|
# Store in the DB only the ones we didn't know about
|
|
|
|
events = await create_unpublished_events(future_events)
|
|
|
|
logger.debug(f"There are now {len(events)} unpublished events.")
|
|
|
|
return events
|