election_day.collections.archived_results
Attributes
Classes
Provides collections with pagination, if they implement a few |
Functions
|
Module Contents
- election_day.collections.archived_results.groupbydict(items: Iterable[_T1], keyfunc: Callable[[_T1], _TSupportsRichComparison], sortfunc: None = None, groupfunc: Callable[[Iterable[_T1]], list[_T1]] = list) dict[_TSupportsRichComparison, list[_T1]] [source]
- election_day.collections.archived_results.groupbydict(items: Iterable[_T1], keyfunc: Callable[[_T1], _T2], sortfunc: Callable[[_T1], SupportsRichComparison], groupfunc: Callable[[Iterable[_T1]], list[_T1]] = list) dict[_T2, list[_T1]]
- election_day.collections.archived_results.groupbydict(items: Iterable[_T1], keyfunc: Callable[[_T1], _TSupportsRichComparison], sortfunc: None = None, *, groupfunc: Callable[[Iterable[_T1]], _T2]) dict[_TSupportsRichComparison, _T2]
- election_day.collections.archived_results.groupbydict(items: Iterable[_T1], keyfunc: Callable[[_T1], _TSupportsRichComparison], sortfunc: None, groupfunc: Callable[[Iterable[_T1]], _T2]) dict[_TSupportsRichComparison, _T2]
- election_day.collections.archived_results.groupbydict(items: Iterable[_T1], keyfunc: Callable[[_T1], _T2], sortfunc: Callable[[_T1], SupportsRichComparison], groupfunc: Callable[[Iterable[_T1]], _T3]) dict[_T2, _T3]
- class election_day.collections.archived_results.ArchivedResultCollection(session: sqlalchemy.orm.Session, date_: str | None = None)[source]
-
- query() Query[ArchivedResult] [source]
- group_items(items: Collection[ArchivedResult], request: onegov.election_day.request.ElectionDayRequest) dict[datetime.date, dict[str | None, dict[str, list[onegov.election_day.models.ArchivedResult]]]] | None [source]
Groups a list of archived results.
Groups election compounds and elections to the same group. Removes elections already covered by an election compound. Merges region, district and none domains.
- current() tuple[list[onegov.election_day.models.ArchivedResult], datetime | None] [source]
Returns the current results.
The current results are the results from either the next election day relative to today or the last results relative to today, if no next.
- by_year(year: int) tuple[list[onegov.election_day.models.ArchivedResult], datetime | None] [source]
Returns the results for the given year.
- by_date(date_: datetime.date | None = None) tuple[list[onegov.election_day.models.ArchivedResult], datetime | None] [source]
Returns the results of a given/current date.
- update(item: onegov.election_day.models.Election | onegov.election_day.models.ElectionCompound | onegov.election_day.models.Vote, request: onegov.election_day.request.ElectionDayRequest, old: str | None = None) onegov.election_day.models.ArchivedResult [source]
Updates a result.
- update_all(request: onegov.election_day.request.ElectionDayRequest) None [source]
Updates all (local) results.
- add(item: onegov.election_day.models.Election | onegov.election_day.models.ElectionCompound | onegov.election_day.models.Vote, request: onegov.election_day.request.ElectionDayRequest) None [source]
Add a new election or vote and create a result entry.
- class election_day.collections.archived_results.SearchableArchivedResultCollection(app: onegov.election_day.app.ElectionDayApp, date_: str | None = None, from_date: datetime.date | None = None, to_date: datetime.date | None = None, item_type: str | None = None, domains: list[str] | None = None, term: str | None = None, answers: list[str] | None = None, locale: str = 'de_CH', page: int = 0)[source]
Bases:
ArchivedResultCollection
,onegov.core.collection.Pagination
[onegov.election_day.models.ArchivedResult
]Provides collections with pagination, if they implement a few documented properties and methods.
See
onegov.ticket.TicketCollection
for an example.- __eq__(other: object) bool [source]
Returns True if the current and the other Pagination instance are equal. Used to find the current page in a list of pages.
- subset() Query[ArchivedResult] [source]
Returns an SQLAlchemy query containing all records that should be considered for pagination.
- page_by_index(index: int) Self [source]
Returns the page at the given index. A page here means an instance of the class inheriting from the
Pagination
base class.
- static term_to_tsquery_string(term: str | None) str [source]
Returns the current search term transformed to use within Postgres
to_tsquery
function. Removes all unwanted characters, replaces prefix matching, joins word together using FOLLOWED BY.
- static match_term(column: ColumnElement[Any], language: str, term: str) ColumnElement[TSVECTOR | None] [source]
Generate a clause element for a given search term.
Usage:
model.filter(match_term(model.col, 'german', 'my search term'))
- static filter_text_by_locale(column: ColumnElement[Any], term: str, locale: str = 'en') ColumnElement[TSVECTOR | None] [source]
Returns an SQLAlchemy filter statement based on the search term. If no locale is provided, it will use english as language.
to_tsquery
creates a tsquery value from term, which must consist ofsingle tokens separated by these Boolean operators:
&
(AND)|
(OR)!
(NOT)
to_tsvector
parses a textual document into tokens, reduces the tokens to lexemes, and returns a tsvector which lists the lexemes together with their positions in the document.The document is processed according to the specified or default text search configuration.
- property term_filter: tuple[ColumnElement[TSVECTOR | None], ColumnElement[TSVECTOR | None]][source]
- query() Query[ArchivedResult] [source]
- classmethod for_item_type(app: onegov.election_day.app.ElectionDayApp, item_type: Literal['vote', 'election'], *, date_: str | None = None, from_date: datetime.date | None = None, to_date: datetime.date | None = None, domains: list[str] | None = None, term: str | None = None, answers: list[str] | None = None, locale: str = 'de_CH', page: int = 0) Self [source]
- classmethod for_item_type(app: onegov.election_day.app.ElectionDayApp, item_type: str | None, *, date_: str | None = None, from_date: datetime.date | None = None, to_date: datetime.date | None = None, domains: list[str] | None = None, term: str | None = None, answers: list[str] | None = None, locale: str = 'de_CH', page: int = 0) Self | None