Make the visitor counter increment when a new session is created

This commit is contained in:
swagg boi 2022-04-03 21:34:22 -04:00
parent 3532310738
commit 27ec34b208
2 changed files with 8 additions and 2 deletions

View file

@ -40,7 +40,13 @@ under sub ($c) {
# https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network
$c->res->headers->header('Permissions-Policy', 'interest-cohort=()');
$c->session(expiration => 86400);
unless ($c->session('counted')) {
$c->counter->increment_visitor_count();
$c->session(
expiration => 86400,
counted => 'true'
);
}
$c->stash(status => 403) if $c->flash('error');

View file

@ -19,7 +19,7 @@ sub get_visitor_count($self) {
}
sub increment_visitor_count($self) {
$self->pg->db->query(<<~'END_SQL')->text()
$self->pg->db->query(<<~'END_SQL')
UPDATE counters
SET counter_value = counter_value + 1
WHERE counter_name = 'visitor';