This is the next iteration of the event database used by the municipality of Aarhus.
This repository contains the frontend API, if you are looking for the event imports, the code is located here.
The event database is an API platform for event aggregation from the public vendors throughout the cites. It gets data mainly from feeds (JSON/XML) or APIs provided by the vendors. It is highly configurable in doing custom feed mappings and extendable to read data from APIs and map this data to event. It also has a user interface to allow manual entering of events.
The data input is pulled/pushed from a range of differently formatted sources and normalized into an event format that can be used across platforms.
For more detailed and technical documentation, see the docs folder in this repository.
This project utilizes record architecture decisions documents which can be located in https://github.com/itk-dev/event-database-imports/tree/develop/docs in this repository.
docker compose up --detach
docker compose exec phpfpm composer install
The project comes with doctrine fixtures to help development on local machines. They can be loaded with the standard doctrine fixture load command:
docker compose exec phpfpm bin/console app:fixtures:load <index>
<index>
must be one of events
, organizations
, occurrences
, daily_occurrences
, tags
, vocabularies
or
locations
(cf. src/Model/IndexName.php
).
The fixtures are related to the backend where the fixtures are generated by using the app:index:dump
command. The load
above command downloads the fixtures from
GitHub and loads them into
ElasticSearch.
Tip
Use task fixtures:load
to load all fixtures into Elasticsearch.
Caution
If the task fixtures:load
command (or any bin/console app:fixtures:load
incantation) fails with an error like
No alive nodes. All the 1 nodes seem to be down.
you must reset the Elasticsearch service to be ready for requests, e.g. by running
docker compose exec elasticsearch curl 'http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=5s' --verbose
until it returns HTTP/1.1 200 OK
(cf. How to Implement Elasticsearch Health Check in Docker
Compose).
Alternatively, you can run docker compose up --detach --wait
to recreate all services and
(automatically) wait for Elasticsearch to be ready – it takes a while …
To access the API, a valid API key must be presented in the X-Api-Key
header, e.g.
curl --header "X-Api-Key: api_key_1" "http://$(docker compose port nginx 8080)/api/v2/events"
Valid API keys are defined via the APP_API_KEYS
environment variable:
# .env.local
APP_API_KEYS='[
{"username": "user_1", "apikey": "api_key_1"},
{"username": "user_2", "apikey": "api_key_2"}
]'
When installing composer and Symfony based application in production, you should not install development packages, hence use this command:
docker compose exec phpfpm composer install --no-dev --optimize-autoloader
Get events with(out) public access:
curl --silent --header "X-Api-Key: api_key_1" "http://$(docker compose port nginx 8080)/api/v2/events?publicAccess=true" | docker run --rm --interactive ghcr.io/jqlang/jq:latest '.["hydra:member"]|length'
curl --silent --header "X-Api-Key: api_key_1" "http://$(docker compose port nginx 8080)/api/v2/events?publicAccess=false" | docker run --rm --interactive ghcr.io/jqlang/jq:latest '.["hydra:member"]|length'
task fixtures:load:test --yes
task api:test
You can pass additional arguments to filter tests, e.g.
task api:test -- --filter Event
Tip
Use Task's Dry run mode (task --dry
) to see the commands that are
actually run, e.g.
$ task --dry api:test -- --filter Event
task: [compose] docker compose exec phpfpm bin/phpunit --filter Event
This is useful to tweak a (test) command without changing Taskfile.yml
.