Skip to content

Commit ba267bb

Browse files
committed
History: Add id and uid dashboard attributes to report
1 parent bc69e83 commit ba267bb

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ in progress
1010
- Caching: Optionally configure TTL using environment variable ``CACHE_TTL``
1111
- History: Stop ``grafana-wtf log <UID>`` acquiring *all* dashboards
1212
- Refactoring: Move all report renderers to ``grafana_wtf.report``
13+
- History: Add ``id`` and ``uid`` dashboard attributes to report
1314

1415
2023-03-05 0.14.1
1516
=================

grafana_wtf/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,15 @@ def log(self, dashboard_uid=None):
376376
dashboard_versions = self.get_dashboard_versions(dashboard_data["id"])
377377
for dashboard_revision in dashboard_versions:
378378
entry = OrderedDict(
379+
version=dashboard_revision["version"],
379380
datetime=dashboard_revision["created"],
380381
user=dashboard_revision["createdBy"],
381382
message=dashboard_revision["message"],
382383
folder=dashboard_meta.get("folderTitle"),
383384
title=dashboard_data["title"],
384-
version=dashboard_revision["version"],
385385
url=urljoin(self.grafana_url, dashboard_meta["url"]),
386+
id=dashboard_data["id"],
387+
uid=dashboard_data["uid"],
386388
)
387389
entries.append(entry)
388390

tests/test_commands.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,20 @@ def test_log_json_success(ldi_resources, capsys, caplog):
234234
assert 'Aggregating edit history for Grafana dashboard "ioUrPwQiz"' in caplog.text
235235

236236
reference = {
237+
"version": 1,
237238
# "datetime": "2021-09-29T17:32:23Z",
238239
"user": "admin",
239240
"message": "",
240241
"folder": "Testdrive",
241242
"title": "luftdaten.info generic trend v27",
242-
"version": 1,
243243
"url": "http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend-v27",
244+
"uid": "ioUrPwQiz",
244245
}
245246

246247
history = json.loads(captured.out)
247248
item = history[-1]
248249
del item["datetime"]
250+
del item["id"]
249251

250252
assert item == reference
251253

0 commit comments

Comments
 (0)