Skip to content

Commit

Permalink
doc: write doc about creating new fetchers
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed May 2, 2024
1 parent 0e35f32 commit 7f01520
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,28 @@ Compatibility with core CKAN versions:

## Config settings


List of config options:

# Caching strategy for chart data (required, default: redis).
ckanext.charts.cache_strategy = disk

# Time to live for the Redis cache in seconds. Set 0 to disable cache (default: 3600)
ckanext.charts.redis_cache_ttl = 7200

# Time to live for the File cache in seconds. Set 0 to disable cache.
ckanext.charts.file_cache_ttl = 0

## Cache

The extension implement a cache strategy to store the data fetched from the different sources. There are two cache strategies available: `redis` and `file`. The file cache works by storing the data in an `orc` file in the filesystem. The redis cache stores the data in a Redis database. The cache strategy can be changed at the CKAN configuration level through the admin interface or in a configuration file.

## Implementing new fetchers

Fetchers are responsible for fetching data from different sources (DataStore, URL, file system, hardcoded data).

To register new fetchers, you need to create a new class that inherits from `DataFetcherStrategy` and implements the `fetch_data` and `make_cache_key` methods.
The `fetch_data` method should return a `pandas` `DataFrame` object with the data that should be displayed in the chart.
The `make_cache_key` method should return a unique string that will be used as a key to store the data in the cache.

## Developer installation

Expand Down
4 changes: 2 additions & 2 deletions ckanext/charts/config_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ fields:

- field_name: ckanext.charts.redis_cache_ttl
label: Redis Cache TTL
help_text: Time to live for the cache in seconds. Set 0 to disable cache.
help_text: Time to live for the Redis cache in seconds. Set 0 to disable cache.
input_type: number

- field_name: ckanext.charts.file_cache_ttl
label: File Cache TTL
help_text: Time to live for the cache in seconds. Set 0 to disable cache.
help_text: Time to live for the File cache in seconds. Set 0 to disable cache.
input_type: number

0 comments on commit 7f01520

Please sign in to comment.