mirror of
https://github.com/Tech-Workers-Coalition-Italia/mobilizon-reshare.git
synced 2024-12-12 17:07:38 +01:00
370e00d187
* 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
28 lines
805 B
Python
28 lines
805 B
Python
from enum import IntEnum
|
|
|
|
from mobilizon_reshare.models.publication import Publication, PublicationStatus
|
|
|
|
|
|
class _EventPublicationStatus(IntEnum):
|
|
WAITING = 1
|
|
FAILED = 2
|
|
COMPLETED = 3
|
|
PARTIAL = 4
|
|
|
|
|
|
def _compute_event_status(publications: list[Publication],) -> _EventPublicationStatus:
|
|
if not publications:
|
|
return _EventPublicationStatus.WAITING
|
|
|
|
unique_statuses: set[PublicationStatus] = set(pub.status for pub in publications)
|
|
|
|
if unique_statuses == {
|
|
PublicationStatus.COMPLETED,
|
|
PublicationStatus.FAILED,
|
|
}:
|
|
return _EventPublicationStatus.PARTIAL
|
|
elif len(unique_statuses) == 1:
|
|
return _EventPublicationStatus[unique_statuses.pop().name]
|
|
|
|
raise ValueError(f"Illegal combination of PublicationStatus: {unique_statuses}")
|