mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-19 14:36:22 -05:00
* Search results sort as the filter dialog says Docs sorted ascending orders backwards and fell back to id order for every descending order (`-size`, `-published_datetime`); it now takes the same `-` prefixed orders as the other searches and rejects unknown ones with a 400. Archives and Docs searches without an order now put the most relevant results first, as Videos does and as the dialog shows. Rank has no direction in the dialog: choosing it sends `rank` (most relevant first) instead of inheriting a descending `-rank` (least relevant first). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * An old -rank link becomes rank when the filter dialog closes The dialog shows Rank without a direction, but it seeded its draft from the URL unchanged, so Done left a saved `-rank` (least relevant first) in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import dataclasses
|
|
from typing import Optional
|
|
|
|
from wrolpi.errors import ValidationError
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class DocSearchRequest:
|
|
search_str: Optional[str] = None
|
|
author: Optional[str] = None
|
|
subject: Optional[str] = None
|
|
language: Optional[str] = None
|
|
mimetype: Optional[str] = None
|
|
tag_names: Optional[list] = dataclasses.field(default_factory=list)
|
|
order_by: Optional[str] = None # Most relevant first when searching, otherwise newest first.
|
|
limit: int = 20
|
|
offset: int = 0
|
|
deep: bool = False # When True, search all text including document contents (d_text)
|
|
any_tag: bool = False # When True, only Docs with at least one Tag.
|
|
|
|
def __post_init__(self):
|
|
if self.any_tag and self.tag_names:
|
|
raise ValidationError('Cannot use both tag_names and any_tag.')
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class DocSearchResponse:
|
|
file_groups: list = dataclasses.field(default_factory=list)
|
|
totals: dict = dataclasses.field(default_factory=dict)
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class DocStatisticsResponse:
|
|
statistics: dict = dataclasses.field(default_factory=dict)
|