Utility Functions
enforce_retention(repo=None, days=None)
Remove the events that are older than the retention period.
Nothing runs this automatically: schedule it, e.g. with the
ckan event-audit enforce-retention command or from a background job.
| PARAMETER | DESCRIPTION |
|---|---|
repo
|
The repository to clean up. The active one is used by default.
TYPE:
|
days
|
The retention period in days. The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Result
|
The result of the operation. It's unsuccessful if the repository can't |
Result
|
remove events by time range. |
get_active_repo(ignore_cache=False)
Get the active repository.
The active repository is the one that is currently configured in the extension configuration.
| RETURNS | DESCRIPTION |
|---|---|
AbstractRepository
|
The active repository. |
get_available_exporters()
Retrieve a dictionary of available exporters.
This function collects and returns a dictionary where the keys are exporter names (as strings) and the values are the corresponding exporter classes.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, type[AbstractExporter]]
|
A dictionary mapping exporter names to their respective exporter classes. |
get_available_repos()
Retrieve a dictionary of available repositories.
This function collects and returns a dictionary where the keys are repository names (as strings) and the values are the corresponding repository classes.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, type[AbstractRepository]]
|
A dictionary mapping repository names to their respective repository classes. |
get_exporter(exporter_name)
Retrieve an exporter class by name.
This function retrieves an exporter class by name. If the exporter is not found, a ValueError is raised.
| PARAMETER | DESCRIPTION |
|---|---|
exporter_name
|
The name of the exporter to retrieve.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
type[AbstractExporter]
|
The exporter class. |
get_repo(repo_name)
Retrieve a repository class by name.
This function retrieves a repository class by name. If the repository is not found, a ValueError is raised.
| PARAMETER | DESCRIPTION |
|---|---|
repo_name
|
The name of the repository to retrieve.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AbstractRepository
|
The repository class. |
test_active_connection()
Test the connection to the active repository.
When we test the connection, we store the result in the repository object, so we can reuse it later.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
whether the connection is active |