audit_trail.query¶
Read path: grouped listing, object history and entry details.
AuditQuery.list_groups lists audit entries grouped by database
transaction, newest first, with keyset pagination. It runs in two stages:
- One query per requested severity (
LIMIT limit + 1each, merged in Python) collects the ids of the page's transactions. A single-severity query reads the monthly partitions in order and stops at the limit; a query over several severities would read all of their rows. - The complete groups are fetched with
transaction_id IN (...)and explicitcreated_atbounds, so only the partitions of the page's time range are read, and theiraudit_transactionrows likewise.
object_history and related page through transactions the same way,
with their own stage 1 streams: the object and target indexes for a record's
history, the correlation index for related transactions. get reads one
entry by (id, created_at), which prunes to one monthly partition per
severity (one partition when the severity is given), and access_summary
counts an object's accesses per actor. LabelResolver labels the objects
that foreign-key and relationship changes refer to.
Every query runs after SET LOCAL plan_cache_mode = 'force_custom_plan':
a generic plan of a prepared statement (asyncpg, psycopg after a few
executions) cannot prune partitions by the query's parameters at plan time.
The setting and the query run on one connection of the session: the one for
the audit tables, that is their bind in Session(binds=...), else the
session's default bind; with neither, UnboundExecutionError is raised.
FieldChange
module-attribute
¶
A column change [old, new] or a relationship change.
ALL_HISTORY
module-attribute
¶
Pass as since to list the whole log, even with a default query window.
since=None means "not given", which applies the configured window.
FieldLabels
module-attribute
¶
Labels of one change: [old, new] for a column (None where the value
is None) or RelationshipLabels for a relationship.
ActivityData ¶
Bases: _ActivityDataBase
The data envelope of an activity row.
Attributes:
| Name | Type | Description |
|---|---|---|
v |
int
|
Envelope version. |
changes |
dict[str, FieldChange]
|
|
payload |
dict[str, JSONValue]
|
Payload of a custom event. |
context |
ContextSnapshot
|
Request context snapshot taken when the entry was written. |
ActivityRow ¶
Bases: TypedDict
One audit_activity row, as fetched from the database.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Row id. |
transaction_id |
int
|
Id of the audit transaction the row belongs to. |
verb |
str
|
Event verb, e.g. |
severity |
int
|
Severity value. |
object_type |
str | None
|
Type of the changed object. |
object_id |
str | None
|
Id of the changed object. |
object_label |
str | None
|
Label of the object when the row was written. |
target_type |
str | None
|
Type of the parent object. |
target_id |
str | None
|
Id of the parent object. |
actor_id |
str | None
|
Actor of the event. |
scope_id |
str | None
|
Scope, e.g. a tenant. |
correlation_id |
UUID | None
|
Correlation id of the transaction. |
created_at |
datetime
|
Start of the database transaction. |
data |
ActivityData
|
The |
AllHistory ¶
Bases: Enum
Type of ALL_HISTORY: a listing without a lower time bound.
Cursor ¶
Bases: NamedTuple
Position in the listing: (created_at, id) of an activity row.
list_groups continues with the rows after it in
(created_at DESC, id DESC) order. The cursor also carries the lower
time bound of the listing, so that every page uses the bound of the
first one.
Attributes:
| Name | Type | Description |
|---|---|---|
created_at |
datetime
|
|
id |
int
|
|
since |
datetime | AllHistory | None
|
The listing's lower bound: a timezone-aware datetime, or
|
encode ¶
Return the cursor as an opaque, URL-safe token.
Returns:
| Type | Description |
|---|---|
str
|
Unpadded URL-safe base64 of |
str
|
by |
str
|
recorded. |
Source code in audit_trail/query.py
decode
classmethod
¶
Parse a token made by encode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
The token. |
required |
Returns:
| Type | Description |
|---|---|
Cursor
|
The cursor. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The token is malformed or one of its datetimes has no offset. |
Source code in audit_trail/query.py
Visibility
dataclass
¶
Visibility(
object_types: Collection[str] | None = None,
verbs: Collection[str] | None = None,
scope_ids: Collection[str] | None = None,
)
What the caller may see; applied to every row the query returns.
The library knows nothing about the host's permissions: the host builds a
Visibility from its own rules. It restricts both which transactions
are listed and which of their entries a group shows.
Each field is a set of allowed values. None means no restriction; an
empty collection allows nothing. A row whose column is NULL never
passes a restriction that is set, so access control fails closed: with
scope_ids={"t1"}, entries without a scope are hidden.
Attributes:
| Name | Type | Description |
|---|---|---|
object_types |
Collection[str] | None
|
Allowed |
verbs |
Collection[str] | None
|
Allowed |
scope_ids |
Collection[str] | None
|
Allowed |
Raises:
| Type | Description |
|---|---|
TypeError
|
A field is a |
predicate ¶
Return the SQL condition on audit_activity rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
The |
required |
Returns:
| Type | Description |
|---|---|
ColumnElement[bool]
|
The condition; |
Source code in audit_trail/query.py
TransactionHeader
dataclass
¶
TransactionHeader(
id: int,
issued_at: datetime,
actor_type: str | None,
actor_id: str | None,
actor_label: str | None,
remote_addr: str | None,
user_agent: str | None,
method: str | None,
path: str | None,
channel: str | None,
auth_method: str | None,
request_id: UUID | None,
correlation_id: UUID | None,
scope_id: str | None,
meta: dict[str, JSONValue] | None,
from_snapshot: bool,
)
Who, where and how of one group: its audit_transaction row.
When the row no longer exists (retention), the header is built from the
data.context snapshot of the group's earliest visible entry and from
that entry's columns, and from_snapshot is True.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
The transaction id. |
issued_at |
datetime
|
Start of the database transaction ( |
actor_type |
str | None
|
Kind of actor; |
actor_id |
str | None
|
Actor id; from a snapshot, the entry's |
actor_label |
str | None
|
Actor label when the transaction started. |
remote_addr |
str | None
|
Client address. |
user_agent |
str | None
|
Client user agent. |
method |
str | None
|
Request method. |
path |
str | None
|
Request path. |
channel |
str | None
|
Channel, e.g. |
auth_method |
str | None
|
Authentication method. |
request_id |
UUID | None
|
Request id. |
correlation_id |
UUID | None
|
Correlation id. |
scope_id |
str | None
|
|
meta |
dict[str, JSONValue] | None
|
Extra host context. |
from_snapshot |
bool
|
Whether the header was rebuilt from an entry. |
Group
dataclass
¶
The entries of one database transaction.
Attributes:
| Name | Type | Description |
|---|---|---|
transaction |
TransactionHeader
|
The transaction header. |
activities |
list[ActivityRow]
|
The visible entries of every severity, in |
Page
dataclass
¶
One page of groups.
A page may hold fewer groups than the limit even when more follow (a
group whose entries compaction hides entirely is left out); only
next_cursor is None ends the listing.
Attributes:
| Name | Type | Description |
|---|---|---|
groups |
list[Group]
|
Groups, newest first. |
next_cursor |
Cursor | None
|
Cursor of the next page, or |
since |
datetime | None
|
The lower time bound the listing used ( |
ActivityDetail
dataclass
¶
One entry with the header of its transaction.
Attributes:
| Name | Type | Description |
|---|---|---|
activity |
ActivityRow
|
The entry, as stored (not compacted). |
transaction |
TransactionHeader
|
The header of its transaction, rebuilt from the entry's
snapshot when the |
AccessCount ¶
Bases: NamedTuple
How often one actor accessed an object.
Attributes:
| Name | Type | Description |
|---|---|---|
actor_id |
str | None
|
The actor; |
entries |
int
|
Number of matching entries. |
first_at |
datetime
|
|
last_at |
datetime
|
|
RelationshipLabels ¶
Bases: TypedDict
Labels of the members a relationship change added and removed.
Attributes:
| Name | Type | Description |
|---|---|---|
added |
list[str]
|
Labels of the added members, in the order of their ids. |
removed |
list[str]
|
Labels of the removed members, in the order of their ids. |
AuditQuery ¶
AuditQuery(
tables: AuditTables,
severities: Iterable[int],
*,
default_window: timedelta | None = None,
)
Queries over the audit tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
AuditTables
|
The audit tables. |
required |
severities
|
Iterable[int]
|
Every severity in use; |
required |
default_window
|
timedelta | None
|
How far back |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
|
ValueError
|
|
Source code in audit_trail/query.py
list_groups ¶
list_groups(
session: Session,
*,
severities: Collection[int] | None = None,
since: datetime | AllHistory | None = None,
until: datetime | None = None,
actor_id: str | None = None,
object_type: str | None = None,
object_id: str | None = None,
target_type: str | None = None,
target_id: str | None = None,
verbs: Collection[str] | None = None,
scope_ids: Collection[str] | None = None,
correlation_id: UUID | None = None,
visibility: Visibility | None = None,
extra_predicate: ColumnElement[bool] | None = None,
cursor: Cursor | None = None,
limit: int = 50,
compact: bool = True,
) -> Page
List entries grouped by database transaction, newest first.
The filters select which transactions are listed: a transaction is
listed when at least one of its entries matches all of them and
visibility. A group then shows every entry of the transaction
that visibility allows, of any severity: severities and the
other filters narrow the list, they do not control access.
Collection filters take the allowed values: None means no
restriction, an empty collection matches nothing. A NULL column
never matches a restriction that is set.
Pagination counts transactions. A transaction appears whole on the
page holding its newest matching entry and on no other, so following
next_cursor returns every matching transaction exactly once, also
when several transactions share a created_at.
With a default query window (AuditTrail(default_query_window=...))
and no since, the listing starts at until (or now) minus the
window. The first page fixes that bound and its next_cursor
carries it, so later pages neither move nor drop it. Page.since
reports the bound: pass it as until to read the window before.
Statements run in the session's current transaction (one is begun if
needed), on its connection for the audit tables, after
SET LOCAL plan_cache_mode = 'force_custom_plan', which stays in
effect until that transaction ends. On an AUTOCOMMIT connection
the setting has no effect, so prepared statements may fall back to
generic plans that read every partition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session to query with. |
required |
severities
|
Collection[int] | None
|
Severities to list; |
None
|
since
|
datetime | AllHistory | None
|
Only entries with |
None
|
until
|
datetime | None
|
Only entries with |
None
|
actor_id
|
str | None
|
Only entries of this actor. |
None
|
object_type
|
str | None
|
Only entries on objects of this type. |
None
|
object_id
|
str | None
|
Only entries on the object with this id. |
None
|
target_type
|
str | None
|
Only entries whose parent object has this type. |
None
|
target_id
|
str | None
|
Only entries whose parent object has this id. |
None
|
verbs
|
Collection[str] | None
|
Only entries with one of these verbs. |
None
|
scope_ids
|
Collection[str] | None
|
Only entries in one of these scopes. |
None
|
correlation_id
|
UUID | None
|
Only entries with this correlation id. |
None
|
visibility
|
Visibility | None
|
What the caller may see; |
None
|
extra_predicate
|
ColumnElement[bool] | None
|
Further condition on |
None
|
cursor
|
Cursor | None
|
|
None
|
limit
|
int
|
Maximum number of groups on the page. |
50
|
compact
|
bool
|
Merge each object's rows within a transaction (see
|
True
|
Returns:
| Type | Description |
|---|---|
Page
|
The page. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
TypeError
|
A collection filter is a |
UnboundExecutionError
|
The session has neither a bind for the audit tables nor a default bind. |
Source code in audit_trail/query.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |
alist_groups
async
¶
alist_groups(
session: AsyncSession,
*,
severities: Collection[int] | None = None,
since: datetime | AllHistory | None = None,
until: datetime | None = None,
actor_id: str | None = None,
object_type: str | None = None,
object_id: str | None = None,
target_type: str | None = None,
target_id: str | None = None,
verbs: Collection[str] | None = None,
scope_ids: Collection[str] | None = None,
correlation_id: UUID | None = None,
visibility: Visibility | None = None,
extra_predicate: ColumnElement[bool] | None = None,
cursor: Cursor | None = None,
limit: int = 50,
compact: bool = True,
) -> Page
Async variant of list_groups, with the same arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AsyncSession
|
The async session to query with. |
required |
severities
|
Collection[int] | None
|
See |
None
|
since
|
datetime | AllHistory | None
|
See |
None
|
until
|
datetime | None
|
See |
None
|
actor_id
|
str | None
|
See |
None
|
object_type
|
str | None
|
See |
None
|
object_id
|
str | None
|
See |
None
|
target_type
|
str | None
|
See |
None
|
target_id
|
str | None
|
See |
None
|
verbs
|
Collection[str] | None
|
See |
None
|
scope_ids
|
Collection[str] | None
|
See |
None
|
correlation_id
|
UUID | None
|
See |
None
|
visibility
|
Visibility | None
|
See |
None
|
extra_predicate
|
ColumnElement[bool] | None
|
See |
None
|
cursor
|
Cursor | None
|
See |
None
|
limit
|
int
|
See |
50
|
compact
|
bool
|
See |
True
|
Returns:
| Type | Description |
|---|---|
Page
|
The page. |
Raises:
| Type | Description |
|---|---|
ValueError
|
See |
TypeError
|
See |
Source code in audit_trail/query.py
get ¶
get(
session: Session,
id: int,
created_at: datetime,
*,
severity: int | None = None,
visibility: Visibility | None = None,
) -> ActivityDetail | None
Return one entry with its transaction header.
An entry is found by id and created_at together: id alone
would read every partition, while created_at limits the read to
one monthly partition of each severity, and severity (the entry's
own, as a listing row carries it) to exactly one partition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session to query with. |
required |
id
|
int
|
The entry's |
required |
created_at
|
datetime
|
The entry's |
required |
severity
|
int | None
|
The entry's severity, if known. |
None
|
visibility
|
Visibility | None
|
What the caller may see; |
None
|
Returns:
| Type | Description |
|---|---|
ActivityDetail | None
|
The entry and its header, or |
ActivityDetail | None
|
or |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in audit_trail/query.py
aget
async
¶
aget(
session: AsyncSession,
id: int,
created_at: datetime,
*,
severity: int | None = None,
visibility: Visibility | None = None,
) -> ActivityDetail | None
Async variant of get, with the same arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AsyncSession
|
The async session to query with. |
required |
id
|
int
|
See |
required |
created_at
|
datetime
|
See |
required |
severity
|
int | None
|
See |
None
|
visibility
|
Visibility | None
|
See |
None
|
Returns:
| Type | Description |
|---|---|
ActivityDetail | None
|
See |
Raises:
| Type | Description |
|---|---|
ValueError
|
See |
Source code in audit_trail/query.py
object_history ¶
object_history(
session: Session,
object_type: str,
object_id: str,
*,
include_children: bool = True,
since: datetime | None = None,
until: datetime | None = None,
visibility: Visibility | None = None,
cursor: Cursor | None = None,
limit: int = 50,
compact: bool = True,
) -> Page
List the history of one record, grouped by database transaction.
The history holds the entries on the record and, with
include_children, the entries whose target is the record (the
changes of its children). Each group shows only those entries of its
transaction, not the transaction's other entries. visibility
applies to every entry on its own: children of types the caller may
not see are left out, and a visible child's entries are listed even
when the record's own type is hidden.
A child's entries follow the target it had when they were written: a child moved to another parent appears, from the move on, in the new parent's history only.
Pagination works as in list_groups: it counts transactions,
newest first, and next_cursor returns each transaction once. The
default query window does not apply: without since (given or
recorded in cursor) the whole history is listed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session to query with. |
required |
object_type
|
str
|
The record's |
required |
object_id
|
str
|
The record's |
required |
include_children
|
bool
|
Also list the entries targeting the record. |
True
|
since
|
datetime | None
|
Only entries with |
None
|
until
|
datetime | None
|
Only entries with |
None
|
visibility
|
Visibility | None
|
What the caller may see; |
None
|
cursor
|
Cursor | None
|
|
None
|
limit
|
int
|
Maximum number of groups on the page. |
50
|
compact
|
bool
|
Merge each object's rows within a transaction;
|
True
|
Returns:
| Type | Description |
|---|---|
Page
|
The page. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in audit_trail/query.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 | |
aobject_history
async
¶
aobject_history(
session: AsyncSession,
object_type: str,
object_id: str,
*,
include_children: bool = True,
since: datetime | None = None,
until: datetime | None = None,
visibility: Visibility | None = None,
cursor: Cursor | None = None,
limit: int = 50,
compact: bool = True,
) -> Page
Async variant of object_history, with the same arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AsyncSession
|
The async session to query with. |
required |
object_type
|
str
|
See |
required |
object_id
|
str
|
See |
required |
include_children
|
bool
|
See |
True
|
since
|
datetime | None
|
See |
None
|
until
|
datetime | None
|
See |
None
|
visibility
|
Visibility | None
|
See |
None
|
cursor
|
Cursor | None
|
See |
None
|
limit
|
int
|
See |
50
|
compact
|
bool
|
See |
True
|
Returns:
| Type | Description |
|---|---|
Page
|
The page. |
Raises:
| Type | Description |
|---|---|
ValueError
|
See |
Source code in audit_trail/query.py
related ¶
related(
session: Session,
correlation_id: UUID,
*,
since: datetime | None = None,
until: datetime | None = None,
visibility: Visibility | None = None,
cursor: Cursor | None = None,
limit: int = 50,
compact: bool = True,
) -> Page
List the transactions sharing a correlation id, newest first.
Groups and pagination are those of list_groups; the transactions
are selected with one query over the correlation index. The default
query window does not apply, as for object_history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session to query with. |
required |
correlation_id
|
UUID
|
The correlation id. |
required |
since
|
datetime | None
|
Only entries with |
None
|
until
|
datetime | None
|
Only entries with |
None
|
visibility
|
Visibility | None
|
What the caller may see; |
None
|
cursor
|
Cursor | None
|
|
None
|
limit
|
int
|
Maximum number of groups on the page. |
50
|
compact
|
bool
|
Merge each object's rows within a transaction;
|
True
|
Returns:
| Type | Description |
|---|---|
Page
|
The page. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in audit_trail/query.py
arelated
async
¶
arelated(
session: AsyncSession,
correlation_id: UUID,
*,
since: datetime | None = None,
until: datetime | None = None,
visibility: Visibility | None = None,
cursor: Cursor | None = None,
limit: int = 50,
compact: bool = True,
) -> Page
Async variant of related, with the same arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AsyncSession
|
The async session to query with. |
required |
correlation_id
|
UUID
|
See |
required |
since
|
datetime | None
|
See |
None
|
until
|
datetime | None
|
See |
None
|
visibility
|
Visibility | None
|
See |
None
|
cursor
|
Cursor | None
|
See |
None
|
limit
|
int
|
See |
50
|
compact
|
bool
|
See |
True
|
Returns:
| Type | Description |
|---|---|
Page
|
The page. |
Raises:
| Type | Description |
|---|---|
ValueError
|
See |
Source code in audit_trail/query.py
access_summary ¶
access_summary(
session: Session,
object_type: str,
object_id: str,
verb: str,
*,
since: datetime | None = None,
until: datetime | None = None,
visibility: Visibility | None = None,
) -> list[AccessCount]
Count one verb's entries on a record per actor.
For example who read a person's sensitive data, and how often.
Entries are counted raw, without compaction. The default query window
does not apply: without since every entry is counted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session to query with. |
required |
object_type
|
str
|
The record's |
required |
object_id
|
str
|
The record's |
required |
verb
|
str
|
The verb to count, e.g. |
required |
since
|
datetime | None
|
Only entries with |
None
|
until
|
datetime | None
|
Only entries with |
None
|
visibility
|
Visibility | None
|
What the caller may see; |
None
|
Returns:
| Type | Description |
|---|---|
list[AccessCount]
|
One count per actor, the most recent access first. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in audit_trail/query.py
aaccess_summary
async
¶
aaccess_summary(
session: AsyncSession,
object_type: str,
object_id: str,
verb: str,
*,
since: datetime | None = None,
until: datetime | None = None,
visibility: Visibility | None = None,
) -> list[AccessCount]
Async variant of access_summary, with the same arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AsyncSession
|
The async session to query with. |
required |
object_type
|
str
|
See |
required |
object_id
|
str
|
See |
required |
verb
|
str
|
See |
required |
since
|
datetime | None
|
See |
None
|
until
|
datetime | None
|
See |
None
|
visibility
|
Visibility | None
|
See |
None
|
Returns:
| Type | Description |
|---|---|
list[AccessCount]
|
See |
Raises:
| Type | Description |
|---|---|
ValueError
|
See |
Source code in audit_trail/query.py
LabelResolver ¶
Labels for the objects that entries' foreign keys and relationships name.
A change such as {"board_id": [1, 2]} stores ids. The resolver finds
which fields refer to other objects from the models' metadata, never from
field names: a column with a single-column ForeignKey to the primary
key of a mapped table, and every relationship (whose tracked changes list
member ids). It then looks each referenced object up in the audit trail,
not in the host's tables.
The label of an object is the newest non-null object_label among its
entries that visibility lets the caller see. So a deleted object keeps
the label of its entity.deleted entry, and an object the caller may
not see (its type, scope or verbs hidden) is not revealed: it gets the
fallback #<id>, as does an object without a labelled entry, e.g. of a
model without a label option. A label is as fresh as the object's
last audited change: an unaudited rename is not reflected.
Not resolved: composite foreign keys, foreign keys to columns other than
the primary key, fields with an audit policy (redact, hash) and
redacted or unknown values, as well as target_type/target_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
AuditTables
|
The audit tables. |
required |
base
|
registry | type[Any]
|
The registry of the models, or a declarative base class using
it, as for |
required |
Source code in audit_trail/query.py
resolve ¶
resolve(
session: Session,
activities: Iterable[ActivityRow],
*,
visibility: Visibility | None = None,
) -> dict[int, dict[str, FieldLabels]]
Label the referenced objects of the entries' changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session to query with. |
required |
activities
|
Iterable[ActivityRow]
|
The entries, e.g. those of a page's groups. |
required |
visibility
|
Visibility | None
|
What the caller may see; |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict[int, dict[str, FieldLabels]]
|
By entry |
|
change |
dict[int, dict[str, FieldLabels]]
|
|
dict[int, dict[str, FieldLabels]]
|
relationship. Entries without reference fields are left out. |
Source code in audit_trail/query.py
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 | |
aresolve
async
¶
aresolve(
session: AsyncSession,
activities: Iterable[ActivityRow],
*,
visibility: Visibility | None = None,
) -> dict[int, dict[str, FieldLabels]]
Async variant of resolve, with the same arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AsyncSession
|
The async session to query with. |
required |
activities
|
Iterable[ActivityRow]
|
See |
required |
visibility
|
Visibility | None
|
See |
None
|
Returns:
| Type | Description |
|---|---|
dict[int, dict[str, FieldLabels]]
|
See |
Source code in audit_trail/query.py
changed_fields ¶
Return the names of the fields an entry changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
activity
|
ActivityRow
|
An entry. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The keys of |