goatcounter icon indicating copy to clipboard operation
goatcounter copied to clipboard

One item is put under the section of 'Show more' instead of sorting as a whole

Open patrickdung opened this issue 4 years ago • 5 comments

The sorting should be as a whole, from the most page view to fewer page view. I found one item that has more page view in previous items is put under 'show more section'

Here's the screenshots.

Before clicking show more before-clicking-show-more

After clicking show more after-clicking-show-more

Goatcounter version is 2.1.1

patrickdung avatar Jan 02 '22 07:01 patrickdung

Curious, I don't recall ever seeing this before, or have someone report something like this.

Are you using SQLite or PostgreSQL?

arp242 avatar Jan 02 '22 11:01 arp242

Also, is that /posts/security/... listed at all in the initial page load? Or only when clicking "load more"?

arp242 avatar Jan 02 '22 11:01 arp242

I am using PostgreSQL. The /posts/security/... post did not appear in the initial page load. It only appears after clicking the load more button.

patrickdung avatar Jan 02 '22 11:01 patrickdung

Same problem here, with PostgreSQL 13.6

HorayNarea avatar Mar 06 '22 16:03 HorayNarea

I don't really know what could be causing this; the query is a pretty simple order by. I spent some time going through the code and trying to reproduce it back in January, and again this morning, I can't really see anything.

I just added a debug-dump cookie which will print all queries + results; you can set that in your inspector (only works if -dev is given). The output of that might be useful to determine what exactly is going on.

arp242 avatar Mar 06 '22 17:03 arp242

One case where this is happen is if you load the interface, then wait for a bit, and then click "show more". The way pagination works is that it excludes all the paths that are in the current display. Simplified, on the initial view you get:

select * from page_views
order by count desc limit 10

And on pagination you have:

select * from page_views
where path_id not in (:seen)
order by count desc limit 10

So if you wait an hour before clicking "show more" it may be the case that e.g. the 11th page went from not enough pageviews to show in the top-10 list to the first ranking.

Don't know why I didn't think of this before; was working on some other related code today when it suddenly struck me.

I think this may be the cause?


At any rate, we could insert the new page in the correct position.

arp242 avatar Nov 04 '22 19:11 arp242

I was having server migration and lost the old setting. Besides that, I switched to use internal DB afterwards.

So I do have have the environment to test it anymore .

patrickdung avatar Nov 05 '22 03:11 patrickdung

I just upgraded from 2.3.0 to 2.4.1, looks like it's fixed :tada:

HorayNarea avatar Nov 30 '22 02:11 HorayNarea