mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-25 10:18:38 +02:00
fix: only count get requests as page loads
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
use axum::{
|
use axum::{
|
||||||
extract::{Request, State},
|
extract::{Request, State},
|
||||||
|
http::Method,
|
||||||
middleware::Next,
|
middleware::Next,
|
||||||
response::Response,
|
response::Response,
|
||||||
};
|
};
|
||||||
@@ -19,7 +20,8 @@ where
|
|||||||
S: ProvidesDb + Clone + Send + Sync + 'static,
|
S: ProvidesDb + Clone + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let path = request.uri().path();
|
let path = request.uri().path();
|
||||||
if !path.starts_with("/assets") && !path.contains('.') {
|
// Only count visits/page loads for GET requests to non-asset, non-static paths
|
||||||
|
if request.method() == Method::GET && !path.starts_with("/assets") && !path.contains('.') {
|
||||||
if !session.get::<bool>("counted_visitor").unwrap_or(false) {
|
if !session.get::<bool>("counted_visitor").unwrap_or(false) {
|
||||||
let _ = Analytics::increment_visitors(state.db()).await;
|
let _ = Analytics::increment_visitors(state.db()).await;
|
||||||
session.set("counted_visitor", true);
|
session.set("counted_visitor", true);
|
||||||
|
|||||||
Reference in New Issue
Block a user