~erock/pico.sh

4 3

How prose.sh counts the views of a post?

Details
Message ID
<_7f7ZEAO6HqYRzZBoMlGsGLyGlIXK-83U4WKdHVJRm2iFMODuLuxSu4fOgMh1AABfnBnjWQSpJBpLAHQ_eQq_iISwzedsUXUbbNShj5ceEI=@protonmail.com>
DKIM signature
pass
Download raw message
Hi!
I am curious about how prose.sh detects and counts the views of each post shown in the section "Manage posts" when you access with SSH to prose.sh.

If someone could explain briefly and link to the file in which there is the code that manage it, I will be very thankful!

Thanks in advance!

Regards,
Iván
Thomas Tramley <thomas@tramley.ca>
Details
Message ID
<NqSVxi6--3-9@tramley.ca>
In-Reply-To
<_7f7ZEAO6HqYRzZBoMlGsGLyGlIXK-83U4WKdHVJRm2iFMODuLuxSu4fOgMh1AABfnBnjWQSpJBpLAHQ_eQq_iISwzedsUXUbbNShj5ceEI=@protonmail.com> (view parent)
DKIM signature
pass
Download raw message
Hi Iván,
I'm not an expert, but I took a look at the code for prose and it looks like the visit counter is incremented every time the page is loaded. I've provided a link to where the request handler triggers the increment in the db. There is a `isRequestTrackable` function, but that always returns true (I assume there was intent to add that as an option at some point) so it just increments each time you load the page. I did some testing with that a while back and found that to be true, every time I reloaded the page the visit counter went up.

https://github.com/picosh/pico/blob/main/prose/api.go#L404

Hope that's helpful!

All the best,
Thomas



Feb 12, 2024, 7:21 a.m. by ivanhercaz@protonmail.com:

> Hi!
> I am curious about how prose.sh detects and counts the views of each post shown in the section "Manage posts" when you access with SSH to prose.sh.
>
> If someone could explain briefly and link to the file in which there is the code that manage it, I will be very thankful!
>
> Thanks in advance!
>
> Regards,
> Iván
>
Details
Message ID
<2f5c5b13-ad0e-4577-abef-4f0ff5ce3ac1@app.fastmail.com>
In-Reply-To
<NqSVxi6--3-9@tramley.ca> (view parent)
DKIM signature
pass
Download raw message
Yes, that's how it works!  It's very crude at this point.  We considered doing user agent parsing but didn't get back to working on it.

----- Original message -----
From: Thomas Tramley <thomas@tramley.ca>
To: "Iván Hernández Cazorla" <ivanhercaz@protonmail.com>
Cc: "~erock/pico.sh@lists.sr.ht" <~erock/pico.sh@lists.sr.ht>
Subject: Re: How prose.sh counts the views of a post?
Date: Monday, February 12, 2024 8:31 AM

Hi Iván,
I'm not an expert, but I took a look at the code for prose and it looks like the visit counter is incremented every time the page is loaded. I've provided a link to where the request handler triggers the increment in the db. There is a `isRequestTrackable` function, but that always returns true (I assume there was intent to add that as an option at some point) so it just increments each time you load the page. I did some testing with that a while back and found that to be true, every time I reloaded the page the visit counter went up.

https://github.com/picosh/pico/blob/main/prose/api.go#L404

Hope that's helpful!

All the best,
Thomas



Feb 12, 2024, 7:21 a.m. by ivanhercaz@protonmail.com:

> Hi!
> I am curious about how prose.sh detects and counts the views of each post shown in the section "Manage posts" when you access with SSH to prose.sh.
>
> If someone could explain briefly and link to the file in which there is the code that manage it, I will be very thankful!
>
> Thanks in advance!
>
> Regards,
> Iván
>
Details
Message ID
<N6bDbWDYURMLVsWuaHvHCiidblOQuxOP_hdnmJ3Ms8fAgDrnGWVP1XqSHRbNxPETDZl6R4qxQ-tyy7z6Pl5NErgYqRtzd8txmdWMXX7cBlI=@protonmail.com>
In-Reply-To
<NqSVxi6--3-9@tramley.ca> (view parent)
DKIM signature
pass
Download raw message
> Hi Iván,

Hi Thomas!

> I'm not an expert, but I took a look at the code for prose and it looks like the visit counter is incremented every time the page is loaded. I've provided a link to where the request handler triggers the increment in the db.

Wow! That's really interesting.

> I did some testing with that a while back and found that to be true, every time I reloaded the page the visit counter went up.
> https://github.com/picosh/pico/blob/main/prose/api.go#L404

It is a really nice way to count views of a post, where views are the number of times a post is loaded. Without JS nor intrusive code/resources.

> 
> Hope that's helpful!
> 
> All the best,
> Thomas

Really helpful!

Thank you very much for research!

Regards,
Iván
Details
Message ID
<UbfCkYrgGImXujEYb8jQbSWAZk9L7WBSaeY8qDy7Dwr6HBCDPcvqliR2tMDC3g-ki6BmQXEOITUcuk2BxI7Yj7aAEiOZAkBcfqnyzAbDLT0=@protonmail.com>
In-Reply-To
<2f5c5b13-ad0e-4577-abef-4f0ff5ce3ac1@app.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
Ups, strange, I didn't receive erock's email until after I sent my reply to Thomas, or it was really hidden in my inbox...

> Yes, that's how it works! It's very crude at this point. We considered doing user agent parsing but didn't get back to working on it.

It seems something that works and it is enough, no? It doesn't introduce nothing intrusive.

Regards,
Iván
Reply to thread Export thread (mbox)