Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix views analytics #885

Merged
merged 8 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/clickhouse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ pub async fn init_client_with_database(

user_id UInt64,
project_id UInt64,
monetized Bool DEFAULT True,

ip IPv6,
country String,
user_agent String,
headers Array(Tuple(String, String)),
headers Array(Tuple(String, String))
)
ENGINE = MergeTree()
PRIMARY KEY (project_id, recorded)
PRIMARY KEY (project_id, recorded, ip)
"
))
.execute()
Expand All @@ -71,10 +72,10 @@ pub async fn init_client_with_database(
ip IPv6,
country String,
user_agent String,
headers Array(Tuple(String, String)),
headers Array(Tuple(String, String))
)
ENGINE = MergeTree()
PRIMARY KEY (project_id, recorded)
PRIMARY KEY (project_id, recorded, ip)
"
))
.execute()
Expand All @@ -94,10 +95,10 @@ pub async fn init_client_with_database(

loader String,
game_version String,
parent UInt64,
parent UInt64
)
ENGINE = MergeTree()
PRIMARY KEY (project_id, recorded)
PRIMARY KEY (project_id, recorded, user_id)
"
))
.execute()
Expand Down
40 changes: 20 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use util::cors::default_cors;

use crate::queue::moderation::AutomatedModerationQueue;
use crate::{
// queue::payouts::process_payout,
queue::payouts::process_payout,
search::indexing::index_projects,
util::env::{parse_strings_from_var, parse_var},
};
Expand Down Expand Up @@ -214,25 +214,25 @@ pub fn app_setup(
});
}

// {
// let pool_ref = pool.clone();
// let redis_ref = redis_pool.clone();
// let client_ref = clickhouse.clone();
// scheduler.run(std::time::Duration::from_secs(60 * 60 * 6), move || {
// let pool_ref = pool_ref.clone();
// let redis_ref = redis_ref.clone();
// let client_ref = client_ref.clone();
//
// async move {
// info!("Started running payouts");
// let result = process_payout(&pool_ref, &redis_ref, &client_ref).await;
// if let Err(e) = result {
// warn!("Payouts run failed: {:?}", e);
// }
// info!("Done running payouts");
// }
// });
// }
{
let pool_ref = pool.clone();
let redis_ref = redis_pool.clone();
let client_ref = clickhouse.clone();
scheduler.run(std::time::Duration::from_secs(60 * 60 * 6), move || {
let pool_ref = pool_ref.clone();
let redis_ref = redis_ref.clone();
let client_ref = client_ref.clone();

async move {
info!("Started running payouts");
let result = process_payout(&pool_ref, &redis_ref, &client_ref).await;
if let Err(e) = result {
warn!("Payouts run failed: {:?}", e);
}
info!("Done running payouts");
}
});
}

let ip_salt = Pepper {
pepper: models::ids::Base62Id(models::ids::random_base62(11)).to_string(),
Expand Down
2 changes: 2 additions & 0 deletions src/models/v3/analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub struct PageView {
pub user_id: u64,
// Modrinth Project ID (used for payouts)
pub project_id: u64,
// whether this view will be monetized / counted for payouts
pub monetized: bool,

// The below information is used exclusively for data aggregation and fraud detection
// (ex: page view botting).
Expand Down
Loading
Loading