Skip to content

Commit

Permalink
adding rewards info to support backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Jan 14, 2022
1 parent b22fe48 commit 07849a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/bin/cli/ideascale/mod.rs
Expand Up @@ -197,19 +197,22 @@ fn parse_from_csv(s: &str) -> Filters {

fn read_scores_file(path: &Option<PathBuf>) -> Result<Scores, Error> {
let mut scores = Scores::new();
for record in reader.records() {
let record = record?;
let proposal_id: u32 = record
.get(0)
.expect("Proposal ids should be present in scores file second column")
.parse()
.expect("Proposal ids should be integers");
let rating_given: f32 = record
.get(1)
.expect("Ratings should be present in scores file third column")
.parse()
.expect("Ratings should be floats [0, 5]");
scores.insert(proposal_id, rating_given);
if let Some(path) = path {
let mut reader = csv::Reader::from_path(path)?;
for record in reader.records() {
let record = record?;
let proposal_id: u32 = record
.get(0)
.expect("Proposal ids should be present in scores file second column")
.parse()
.expect("Proposal ids should be integers");
let rating_given: f32 = record
.get(1)
.expect("Ratings should be present in scores file third column")
.parse()
.expect("Ratings should be floats [0, 5]");
scores.insert(proposal_id, rating_given);
}
}
Ok(scores)
}
Expand Down
1 change: 1 addition & 0 deletions src/ideascale/mod.rs
Expand Up @@ -108,6 +108,7 @@ pub fn build_fund(fund: i32, goal: String, threshold: i64) -> Vec<models::se::Fu
id: fund,
goal,
threshold,
rewards_info: "".to_string(),
}]
}

Expand Down
1 change: 1 addition & 0 deletions src/ideascale/models/se.rs
Expand Up @@ -24,6 +24,7 @@ pub struct Fund {
pub id: i32,
pub goal: String,
pub threshold: i64,
pub rewards_info: String,
}

#[derive(Debug, Serialize)]
Expand Down

0 comments on commit 07849a3

Please sign in to comment.