-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from constata-eu/re_score
Re score
- Loading branch information
Showing
826 changed files
with
11,307 additions
and
645 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
api/migrations/20241227110000_store_campaign_tweet_metrics.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
ALTER TABLE campaigns ADD COLUMN impression_count int4 NOT NULL default 0; | ||
ALTER TABLE campaigns ADD COLUMN reply_count int4 NOT NULL default 0; | ||
ALTER TABLE campaigns ADD COLUMN repost_count int4 NOT NULL default 0; | ||
ALTER TABLE campaigns ADD COLUMN like_count int4 NOT NULL default 0; | ||
|
||
ALTER TABLE handles ALTER COLUMN score SET DEFAULT '0x0000000000000000000000000000000000000000000000000000000000000000'; | ||
ALTER TABLE handles ALTER COLUMN score DROP NOT NULL; | ||
ALTER TABLE handles ALTER COLUMN last_scoring DROP NOT NULL; | ||
|
||
ALTER TABLE handles ADD COLUMN avg_impression_count int4 NOT NULL default 0; | ||
ALTER TABLE handles ADD COLUMN avg_reply_count int4 NOT NULL default 0; | ||
ALTER TABLE handles ADD COLUMN avg_repost_count int4 NOT NULL default 0; | ||
ALTER TABLE handles ADD COLUMN avg_like_count int4 NOT NULL default 0; | ||
ALTER TABLE handles ADD COLUMN scored_tweet_count int4 NOT NULL default 0; | ||
ALTER TABLE handles ADD COLUMN legacy_score varchar NOT NULL default '0x0000000000000000000000000000000000000000000000000000000000000000'; | ||
|
||
|
||
UPDATE handles SET legacy_score = score; | ||
UPDATE handles SET last_scoring = NULL; | ||
|
||
INSERT INTO topics (name) VALUES ('speaks_english'), ('speaks_spanish'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
use super::{ | ||
models::{self, *}, | ||
*, | ||
}; | ||
|
||
#[derive(Debug, GraphQLObject, serde::Deserialize, serde::Serialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Topic { | ||
#[graphql(description = "Topic ID as integer")] | ||
id: i32, | ||
#[graphql(description = "Human readable topic name, in english")] | ||
name: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Default, GraphQLInputObject, serde::Serialize, serde::Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct TopicFilter { | ||
pub ids: Option<Vec<i32>>, | ||
pub name_like: Option<String>, | ||
} | ||
|
||
#[rocket::async_trait] | ||
impl Showable<models::Topic, TopicFilter> for Topic { | ||
fn sort_field_to_order_by(field: &str) -> Option<models::TopicOrderBy> { | ||
match field { | ||
"id" => Some(TopicOrderBy::Id), | ||
_ => None, | ||
} | ||
} | ||
|
||
fn filter_to_select(_context: &Context, filter: Option<TopicFilter>) -> FieldResult<models::SelectTopic> { | ||
if let Some(f) = filter { | ||
Ok(models::SelectTopic { | ||
id_in: f.ids, | ||
name_like: into_like_search(f.name_like), | ||
..Default::default() | ||
}) | ||
} else { | ||
Ok(Default::default()) | ||
} | ||
} | ||
|
||
fn select_by_id(_context: &Context, id: i32) -> FieldResult<models::SelectTopic> { | ||
Ok(models::SelectTopic { | ||
id_eq: Some(id), | ||
..Default::default() | ||
}) | ||
} | ||
|
||
async fn db_to_graphql(_context: &Context, d: models::Topic) -> AsamiResult<Self> { | ||
Ok(Topic { | ||
id: d.attrs.id, | ||
name: d.attrs.name, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.