123456789101112131415161718192021222324252627282930313233 |
- from typing import Annotated, List
- from fastapi import FastAPI, Query
- from million.model.filter.MessageFilter import MessageFilter, MessageOrder
- from million.model.filter.ParticipantFilter import ParticipantFilter
- from million.model.message import Message
- from million.analyze.filter.message import filter as message_filter
- from million.analyze.filter.participants import ParticipantCount, filter as participants_filter
- from million.model.participant import Participant
- import million.parse.fb_exports as fb
-
-
- DATA_PATH = './data/'
-
- export = fb.parse_dirfiles(DATA_PATH)
-
- app = FastAPI()
-
-
- class GetMessageForm(MessageFilter):
- order: MessageOrder = None
- limit: int = 100
-
-
- @app.get("/messages")
- def read_messages(
- form: Annotated[GetMessageForm, Query()]
- ) -> List[Message]:
- return message_filter(export.messages, form, form.order, form.limit)
-
-
- @app.get("/participants")
- def read_participants(form: Annotated[ParticipantFilter, Query()]) -> List[ParticipantCount]:
- return participants_filter(export.messages, export.participants, form)
|