Postgres repository
Stores the events in the event_audit_event table of the CKAN database. Run
ckan db upgrade -p event_audit to create it, see Installation.
- Events are written in a separate short-lived session, so they are recorded even if the request that produced them rolls back afterwards.
payloadandresultareJSONBcolumns, and the filters on them use the containment operator (@>), which is served by GIN indexes.- Events can be removed one by one, by filters (a single
DELETEstatement) and all at once. - The dashboard sorts and paginates in the database, so it stays fast with a lot of events.
filter_events(filters)
Filters events based on provided filter criteria.
| PARAMETER | DESCRIPTION |
|---|---|
filters
|
filters to apply.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[Event]
|
List[types.Event]: list of events. |
get_event(event_id)
Retrieves a single event from the repository.
| PARAMETER | DESCRIPTION |
|---|---|
event_id
|
event ID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Event | None
|
types.Event | None: event object or None if not found. |
remove_all_events()
Removes all events from the repository.
| RETURNS | DESCRIPTION |
|---|---|
Result
|
types.Result: result of the operation. |
remove_event(event_id, session=None, defer_commit=False)
Removes a single event from the repository.
| PARAMETER | DESCRIPTION |
|---|---|
event_id
|
event ID.
TYPE:
|
session
|
session to use. When given, the caller owns its lifecycle.
TYPE:
|
defer_commit
|
whether to defer the commit. Only
meaningful together with an explicit
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Result
|
types.Result: result of the operation. |
remove_events(filters)
Removes a filtered set of events from the repository.
| PARAMETER | DESCRIPTION |
|---|---|
filters
|
filters to apply.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Result
|
types.Result: result of the operation. |
test_connection()
Tests the connection to the repository.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
whether the connection was successful.
TYPE:
|
write_event(event, session=None, defer_commit=False)
Writes a single event to the repository.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
event to write.
TYPE:
|
session
|
session to use. When
given, the caller owns its lifecycle (commit and close);
TYPE:
|
defer_commit
|
whether to defer the commit. Only
meaningful together with an explicit
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Result
|
types.Result: result of the operation. |
write_events(events)
Write multiple events to the repository in a single transaction.
| PARAMETER | DESCRIPTION |
|---|---|
events
|
events to write.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Result
|
types.Result: result of the operation. |