mirror of
https://github.com/xai-org/x-algorithm.git
synced 2026-02-13 03:05:06 +01:00
71 lines
2.4 KiB
Rust
71 lines
2.4 KiB
Rust
use std::collections::HashMap;
|
|
use xai_home_mixer_proto as pb;
|
|
use xai_visibility_filtering::models as vf;
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct PostCandidate {
|
|
pub tweet_id: i64,
|
|
pub author_id: u64,
|
|
pub tweet_text: String,
|
|
pub in_reply_to_tweet_id: Option<u64>,
|
|
pub retweeted_tweet_id: Option<u64>,
|
|
pub retweeted_user_id: Option<u64>,
|
|
pub phoenix_scores: PhoenixScores,
|
|
pub prediction_request_id: Option<u64>,
|
|
pub last_scored_at_ms: Option<u64>,
|
|
pub weighted_score: Option<f64>,
|
|
pub score: Option<f64>,
|
|
pub served_type: Option<pb::ServedType>,
|
|
pub in_network: Option<bool>,
|
|
pub ancestors: Vec<u64>,
|
|
pub video_duration_ms: Option<i32>,
|
|
pub author_followers_count: Option<i32>,
|
|
pub author_screen_name: Option<String>,
|
|
pub retweeted_screen_name: Option<String>,
|
|
pub visibility_reason: Option<vf::FilteredReason>,
|
|
pub subscription_author_id: Option<u64>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct PhoenixScores {
|
|
pub favorite_score: Option<f64>,
|
|
pub reply_score: Option<f64>,
|
|
pub retweet_score: Option<f64>,
|
|
pub photo_expand_score: Option<f64>,
|
|
pub click_score: Option<f64>,
|
|
pub profile_click_score: Option<f64>,
|
|
pub vqv_score: Option<f64>,
|
|
pub share_score: Option<f64>,
|
|
pub share_via_dm_score: Option<f64>,
|
|
pub share_via_copy_link_score: Option<f64>,
|
|
pub dwell_score: Option<f64>,
|
|
pub quote_score: Option<f64>,
|
|
pub quoted_click_score: Option<f64>,
|
|
pub follow_author_score: Option<f64>,
|
|
pub not_interested_score: Option<f64>,
|
|
pub block_author_score: Option<f64>,
|
|
pub mute_author_score: Option<f64>,
|
|
pub report_score: Option<f64>,
|
|
// Continuous actions
|
|
pub dwell_time: Option<f64>,
|
|
}
|
|
|
|
pub trait CandidateHelpers {
|
|
fn get_screen_names(&self) -> HashMap<u64, String>;
|
|
}
|
|
|
|
impl CandidateHelpers for PostCandidate {
|
|
fn get_screen_names(&self) -> HashMap<u64, String> {
|
|
let mut screen_names = HashMap::<u64, String>::new();
|
|
if let Some(author_screen_name) = self.author_screen_name.clone() {
|
|
screen_names.insert(self.author_id, author_screen_name);
|
|
}
|
|
if let (Some(retweeted_screen_name), Some(retweeted_user_id)) =
|
|
(self.retweeted_screen_name.clone(), self.retweeted_user_id)
|
|
{
|
|
screen_names.insert(retweeted_user_id, retweeted_screen_name);
|
|
}
|
|
screen_names
|
|
}
|
|
}
|