goatcounter
goatcounter copied to clipboard
Sort options for stats page
Description: Ability to sort the "Pages" module by different parameters.
Ideas:
- Alphabetically (A-Z, Z-A)
- Last visited (newest-oldest, oldest-newest)
- No. of events (already the default/only option)
What's your use case for sorting? I could imagine perhaps some use for alphabetic sorting (although the filter/search should cover that as well), but I'm not sure about last visited?
I've found the filter/search to be a reasonable workaround. A-Z would still be helpful for browsing the data, though.
Use-case would be simply browsing.
I suppose an option could be added for it – turns out this is a lot easier than I thought; I think it just needs tweaking one query. Need to test this with more than just a small test site though, because it may be very slow for larger sites.
By name:
diff --git i/db/query/hit_list.List-counts.sql w/db/query/hit_list.List-counts.sql
index bd28cdb..79b3157 100644
--- i/db/query/hit_list.List-counts.sql
+++ w/db/query/hit_list.List-counts.sql
@@ -7,8 +7,8 @@ with x as (
hour>=:start and hour<=:end
group by path_id
order by total desc, path_id desc
- limit :limit
)
select path_id, paths.path, paths.title, paths.event from x
join paths using (path_id)
-order by total desc, path_id desc
+order by paths.path asc
+limit :limit
And by last seen:
diff --git i/db/query/hit_list.List-counts.sql w/db/query/hit_list.List-counts.sql
index bd28cdb..44d0e26 100644
--- i/db/query/hit_list.List-counts.sql
+++ w/db/query/hit_list.List-counts.sql
@@ -6,9 +6,9 @@ with x as (
{{:filter path_id in (:filter) and}}
hour>=:start and hour<=:end
group by path_id
- order by total desc, path_id desc
+ order by max(hour) asc, path_id desc
limit :limit
)
select path_id, paths.path, paths.title, paths.event from x
join paths using (path_id)
-order by total desc, path_id desc
+-- order by total desc, path_id desc