Enhance newsletter generation and dashboard functionality
- Introduce a new period selection feature in the dashboard for generating newsletters, allowing users to choose between "last month" and "last X days." - Refactor newsletter generation logic to support filtering by article type (new, edited, or all) and improve the handling of filters in the dashboard. - Update the dashboard template to include new input fields for period and article type, enhancing user experience. - Improve CSS styles for send notifications and sections in the dashboard, providing clearer feedback on newsletter sending status.
This commit is contained in:
@@ -19,11 +19,18 @@ class WikiService:
|
||||
def __init__(self) -> None:
|
||||
self.api_url = settings.wiki_api_url
|
||||
|
||||
async def get_recent_changes(self, days: int = 30, only_edited: bool = False) -> list[dict[str, Any]]:
|
||||
now = datetime.now(timezone.utc)
|
||||
start = now - timedelta(days=days)
|
||||
rcstart = now.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
rcend = start.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
async def get_recent_changes(
|
||||
self,
|
||||
days: int = 30,
|
||||
article_type: str = "all",
|
||||
start: datetime | None = None,
|
||||
end: datetime | None = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
# MediaWiki listet neueste Änderungen zuerst: rcstart = obere (neuere) Grenze, rcend = untere (ältere).
|
||||
upper = end or datetime.now(timezone.utc)
|
||||
lower = start or (upper - timedelta(days=days))
|
||||
rcstart = upper.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
rcend = lower.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
params: dict[str, str] = {
|
||||
"action": "query",
|
||||
@@ -35,7 +42,9 @@ class WikiService:
|
||||
"rcend": rcend,
|
||||
"rcnamespace": "0",
|
||||
}
|
||||
if only_edited:
|
||||
if article_type == "new":
|
||||
params["rctype"] = "new"
|
||||
elif article_type == "edited":
|
||||
params["rctype"] = "edit"
|
||||
else:
|
||||
params["rctype"] = "new|edit"
|
||||
|
||||
Reference in New Issue
Block a user