I wanted to create a dashboard in grafana about copr builds and needed to feed the build data into a postgres database. From there I can consume it in Grafana using a Postgres Data Source.
In order to have a simple conversion at hand I've written the script copr-json-to-sql.sh
which prints SQL-INSERT
-statements for the build information in a denomalized form.
The schema for the copr_build_logs
table can be found in copr_build_logs.sql
.
For example, you can call the script to get information about the builds of the @kdesig/python-qt6
project which is featured here.
$ curl -sL 'https://copr.fedorainfracloud.org/api_3/build/list/?ownername=%40kdesig&projectname=python-qt6' \
| copr-json-to-sql.sh
You should see an output similar to this:
INSERT INTO copr_build_logs (
owner_name,
project_name,
submitter,
source_package_name,
source_package_url,
source_package_version,
project_dirname,
state,
repo_url,
build_id,
ended_on_ts,
started_on_ts,
submitted_on,
is_background,
chroots
) VALUES
('@kdesig', 'python-qt6', 'thunderbirdtr', 'python-qt6', 'https://download.copr.fedorainfracloud.org/results/@kdesig/python-qt6/srpm-builds/04200339/python-qt6-6.2.3-1.fc35.src.rpm', '6.2.3-1.fc35', 'python-qt6', 'succeeded', 'https://download.copr.fedorainfracloud.org/results/@kdesig/python-qt6', 4200339, to_timestamp(1649808972), to_timestamp(1649803664), to_timestamp(1649803622), false, ARRAY['fedora-rawhide-x86_64', 'fedora-36-x86_64', 'fedora-rawhide-aarch64', 'fedora-36-aarch64']),
('@kdesig', 'python-qt6', 'thunderbirdtr', 'python-pyqt6-sip', 'https://download.copr.fedorainfracloud.org/results/@kdesig/python-qt6/srpm-builds/04200338/python-pyqt6-sip-13.3.0-1.fc35.src.rpm', '13.3.0-1.fc35', 'python-qt6', 'succeeded', 'https://download.copr.fedorainfracloud.org/results/@kdesig/python-qt6', 4200338, to_timestamp(1649804303), to_timestamp(1649803642), to_timestamp(1649803595), false, ARRAY['fedora-rawhide-x86_64', 'fedora-36-x86_64', 'fedora-rawhide-aarch64', 'fedora-36-aarch64']),
('@kdesig', 'python-qt6', 'thunderbirdtr', 'python-qt6', 'https://download.copr.fedorainfracloud.org/results/@kdesig/python-qt6/srpm-builds/04199264/python-qt6-6.2.3-1.fc35.src.rpm', '6.2.3-1.fc35', 'python-qt6', 'succeeded', 'https://download.copr.fedorainfracloud.org/results/@kdesig/python-qt6', 4199264, to_timestamp(1649802694), to_timestamp(1649797473), to_timestamp(1649796495), false, ARRAY['fedora-rawhide-x86_64', 'fedora-36-x86_64', 'fedora-rawhide-aarch64', 'fedora-36-aarch64'])
ON CONFLICT ON CONSTRAINT copr_build_logs_pkey
DO UPDATE SET
submitter=excluded.submitter,
source_package_name=excluded.source_package_name,
source_package_url=excluded.source_package_url,
source_package_version=excluded.source_package_version,
project_dirname=excluded.project_dirname,
state=excluded.state,
repo_url=excluded.repo_url,
ended_on_ts=excluded.ended_on_ts,
started_on_ts=excluded.started_on_ts,
submitted_on=excluded.submitted_on,
is_background=excluded.is_background,
chroots=excluded.chroots
;