Skip to content

Commit 9564809

Browse files
committed
fix: fix date representation in tables, fix url for datasets
1 parent 54f3dbd commit 9564809

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

ckanext/better_stats/metrics/dataset_metrics.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def get_data(self) -> list[dict[str, Any]]:
145145
.order_by("day")
146146
.all()
147147
)
148-
return [{"day": row.day.strftime("%Y-%m-%d"), "count": row.count} for row in rows]
148+
return [{"day": row.day.strftime("%d %B %Y"), "count": row.count} for row in rows]
149149

150150
def get_chart_data(self) -> dict[str, Any]:
151151
data = self.get_data()
@@ -337,7 +337,7 @@ def get_table_data(self) -> dict[str, Any]:
337337
"rows": [
338338
[
339339
item["title"],
340-
{"text": item["url"], "url": item["url"]},
340+
{"text": item["title"], "url": item["url"]},
341341
]
342342
for item in data
343343
],
@@ -392,7 +392,8 @@ def get_data(self) -> list[dict[str, Any]]:
392392
{
393393
"name": row.name,
394394
"title": row.title or row.name,
395-
"last_updated": row.metadata_modified.strftime("%Y-%m-%d"),
395+
"last_updated": row.metadata_modified.strftime("%d %B %Y"),
396+
"url": tk.url_for("dataset.read", id=row.name, _external=False),
396397
}
397398
for row in rows
398399
]
@@ -404,7 +405,7 @@ def get_table_data(self) -> dict[str, Any]:
404405
data = self.get_data()
405406
return {
406407
"headers": [tk._("Dataset"), tk._("Last Updated")],
407-
"rows": [[item["title"], item["last_updated"]] for item in data],
408+
"rows": [[{"text": item["title"], "url": item["url"]}, item["last_updated"]] for item in data],
408409
}
409410

410411
def get_export_data(self) -> dict[str, Any]:

ckanext/better_stats/metrics/organization_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def get_table_data(self) -> dict[str, Any]:
183183
"rows": [
184184
[
185185
row.title or row[0],
186-
row.created.strftime("%Y-%m-%d") if row.created else "—",
186+
row.created.strftime("%d %B %Y") if row.created else "—",
187187
]
188188
for row in rows
189189
],
@@ -444,7 +444,7 @@ def get_data(self) -> list[dict[str, Any]]:
444444
return [
445445
{
446446
"organization": row.title,
447-
"created": row.created.strftime("%Y-%m-%d") if row.created else "—",
447+
"created": row.created.strftime("%d %B %Y") if row.created else "—",
448448
}
449449
for row in rows
450450
]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ckanext-better-stats"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
description = "Flexible CKAN extension for defining and displaying custom metrics with support for caching, access control, and multiple output formats"
55
readme = "README.md"
66
authors = [

0 commit comments

Comments
 (0)