diff --git a/src/endpoints/mod.rs b/src/endpoints/mod.rs index d39c7001..75633381 100644 --- a/src/endpoints/mod.rs +++ b/src/endpoints/mod.rs @@ -12,6 +12,10 @@ pub mod has_completed_quest; pub mod leaderboard; pub mod quest_boost; pub mod quests; +<<<<<<< Updated upstream pub mod get_boosted_quests; pub mod analytics; pub mod unique_page_visit; +======= +pub mod get_boosted_quests; +>>>>>>> Stashed changes diff --git a/src/endpoints/unique_page_visit.rs b/src/endpoints/unique_page_visit.rs deleted file mode 100644 index a785f768..00000000 --- a/src/endpoints/unique_page_visit.rs +++ /dev/null @@ -1,46 +0,0 @@ -use std::net::SocketAddr; -use crate::{ - models::{AppState}, - utils::get_error, -}; -use axum::{ - extract::{Query, State, ConnectInfo}, - http::StatusCode, - response::IntoResponse, - Json, -}; -use axum_auto_routes::route; -use mongodb::bson::doc; -use serde::Deserialize; -use std::sync::Arc; -use chrono::Utc; -use mongodb::Collection; -use mongodb::options::UpdateOptions; -use serde_json::json; -use crate::models::UniquePageVisit; - -#[derive(Deserialize)] -pub struct GetQuestsQuery { - page_id: String, -} - -#[route(get, "/unique_page_visit", crate::endpoints::unique_page_visit)] -pub async fn handler( - State(state): State>, - Query(query): Query, - ConnectInfo(addr): ConnectInfo, -) -> impl IntoResponse { - let id = query.page_id; - let unique_viewers_collection: Collection = - state.db.collection("unique_viewers"); - let created_at = Utc::now().timestamp_millis(); - let filter = doc! { "viewer_ip": addr.to_string(), "viewed_page_id": &id }; - let update = doc! { "$setOnInsert": { "viewer_ip": addr.to_string(), "viewed_page_id": &id,"timestamp":created_at } }; - let options = UpdateOptions::builder().upsert(true).build(); - - match unique_viewers_collection.update_one(filter, update, options) - .await { - Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(), - Err(_) => get_error("unable to detect page visit status".to_string()), - } -}