Simone Robutti 370e00d187
decouple dataclasses from models (#181)
* fixed parsing bug

* implemented events and publications endpoints

split endpoints by entity

removed credentials

* add pagination (#179)

* added pagination

* integrated pagination with tortoise

* added test for publications

* removed converter file

* moved publications to dataclasses module

* implemented import pattern on dataclasses to prevent circular imports

* removed redundant fetch

* removed unused query

* split build_publications

* split failed_publications

* removed redundant query functions

* split publication retrieve

* split all read functions

* removed redundant write function

* fixed lock
2022-12-11 14:15:04 +01:00

23 lines
770 B
Python

import logging.config
from mobilizon_reshare.dataclasses import MobilizonEvent
from mobilizon_reshare.mobilizon.events import get_mobilizon_future_events
from mobilizon_reshare.storage.query.write import create_unpublished_events
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