Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort options for stats page #718

Open
brandon-toner opened this issue Jan 27, 2024 · 3 comments
Open

Sort options for stats page #718

brandon-toner opened this issue Jan 27, 2024 · 3 comments

Comments

@brandon-toner
Copy link

brandon-toner commented Jan 27, 2024

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)
@arp242
Copy link
Owner

arp242 commented Apr 8, 2024

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?

@brandon-toner
Copy link
Author

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.

@arp242
Copy link
Owner

arp242 commented Apr 8, 2024

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

@arp242 arp242 changed the title [Feature Suggestion] Sort options for stats page Sort options for stats page Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants