Skip to content

Commit 14b13ea

Browse files
authored
Remove ability to hard-code extra trainee data (#27)
We used to have this so that we could patch in trainees who hadn't filled in the spreadsheet with their GitHub accounts. All trainees are now present in the sheet, so we don't need to patch people in any more.
1 parent bcde4aa commit 14b13ea

6 files changed

Lines changed: 5 additions & 28 deletions

File tree

config.prod.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,5 @@
406406
}
407407
}
408408
}
409-
},
410-
411-
"extra_trainee_github_mappings": {
412409
}
413410
}

src/config.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ use indexmap::IndexMap;
55
use serde::Deserialize;
66
use serde_env_field::EnvField;
77

8-
use crate::{
9-
github_accounts::Trainee,
10-
newtypes::{GithubLogin, Region},
11-
};
8+
use crate::newtypes::Region;
129

1310
#[derive(Clone, Deserialize)]
1411
pub struct Config {
@@ -40,9 +37,6 @@ pub struct Config {
4037
pub github_email_mapping_sheet_id: String,
4138

4239
pub reviewer_staff_info_sheet_id: String,
43-
44-
// Legacy hack until all trainees are in the sheet.
45-
pub extra_trainee_github_mappings: BTreeMap<GithubLogin, Trainee>,
4640
}
4741

4842
#[derive(Clone, Deserialize)]

src/course.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -605,14 +605,8 @@ pub async fn get_batch_members(
605605
github_email_mapping_sheet_id: &str,
606606
github_org: &str,
607607
batch_github_slug: &str,
608-
extra_trainees: BTreeMap<GithubLogin, Trainee>,
609608
) -> Result<BatchMembers, Error> {
610-
let trainee_info = get_trainees(
611-
sheets_client.clone(),
612-
github_email_mapping_sheet_id,
613-
extra_trainees,
614-
)
615-
.await?;
609+
let trainee_info = get_trainees(sheets_client.clone(), github_email_mapping_sheet_id).await?;
616610

617611
let members = all_pages("members", octocrab, async || {
618612
octocrab
@@ -654,7 +648,6 @@ pub async fn get_batch_with_submissions(
654648
github_org: &str,
655649
batch_github_slug: &str,
656650
course: &Course,
657-
extra_trainees: BTreeMap<GithubLogin, Trainee>,
658651
) -> Result<Batch, Error> {
659652
let register_info = get_register(
660653
sheets_client.clone(),
@@ -670,7 +663,6 @@ pub async fn get_batch_with_submissions(
670663
github_email_mapping_sheet_id,
671664
github_org,
672665
batch_github_slug,
673-
extra_trainees,
674666
)
675667
.await?;
676668

src/endpoints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ pub async fn get_region(
201201
let trainees = get_trainees(
202202
sheets_client,
203203
&server_state.config.github_email_mapping_sheet_id,
204-
server_state.config.extra_trainee_github_mappings,
205204
)
206205
.await?;
207206
Ok(Json(Region {

src/frontend.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ pub async fn get_trainee_batch(
116116
github_org,
117117
&batch_github_slug,
118118
&course,
119-
server_state.config.extra_trainee_github_mappings,
120119
)
121120
.await?;
122121
batch

src/github_accounts.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::{
1515
pub(crate) async fn get_trainees(
1616
client: SheetsClient,
1717
sheet_id: &str,
18-
extra_trainees: BTreeMap<GithubLogin, Trainee>,
1918
) -> Result<BTreeMap<GithubLogin, Trainee>, Error> {
2019
const EXPECTED_SHEET_NAME: &str = "Form responses 1";
2120
let data = client.get(sheet_id, true, &[]).await.map_err(|err| {
@@ -34,7 +33,7 @@ pub(crate) async fn get_trainees(
3433
}
3534
});
3635
if let Some(sheet) = sheet {
37-
let data = trainees_from_sheet(&sheet, extra_trainees).map_err(|err| {
36+
let data = trainees_from_sheet(&sheet).map_err(|err| {
3837
err.with_context(|| {
3938
format!(
4039
"Failed to read trainees from sheet {}",
@@ -64,11 +63,8 @@ pub struct Trainee {
6463
pub email: EmailAddress,
6564
}
6665

67-
fn trainees_from_sheet(
68-
sheet: &Sheet,
69-
extra_trainees: BTreeMap<GithubLogin, Trainee>,
70-
) -> Result<BTreeMap<GithubLogin, Trainee>, Error> {
71-
let mut trainees = extra_trainees;
66+
fn trainees_from_sheet(sheet: &Sheet) -> Result<BTreeMap<GithubLogin, Trainee>, Error> {
67+
let mut trainees = BTreeMap::new();
7268
for data in &sheet.data {
7369
if data.start_column != 0 || data.start_row != 0 {
7470
return Err(Error::Fatal(anyhow::anyhow!("Reading data from Google Sheets API - got data chunk that didn't start at row=0,column=0 - got row={},column={}", data.start_row, data.start_column)));

0 commit comments

Comments
 (0)