Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::assets::AssetFiles;
use crate::fs::{copy_dir_all, ensure_directory};
use crate::i18n::{EXPLICIT_LOCALE_INFO, LocaleInfo, SUPPORTED_LOCALES};
use crate::rust_version::RustVersion;
use crate::teams::{PageData, RustTeams};
use crate::teams::{PageData, RustTeamData};
use crate::{BaseUrl, ENGLISH, LAYOUT};
use anyhow::Context;
use handlebars::Handlebars;
Expand Down Expand Up @@ -84,7 +84,7 @@ pub struct RenderCtx<'a> {
pub fluent_loader: SimpleLoader,
pub output_dir: PathBuf,
pub rust_version: RustVersion,
pub teams: RustTeams,
pub teams: RustTeamData,
pub assets: AssetFiles,
pub base_url: BaseUrl,
}
Expand Down
50 changes: 34 additions & 16 deletions src/teams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use handlebars::{
Context, Handlebars, Helper, HelperResult, Output, RenderContext, RenderErrorReason,
};
use percent_encoding::{AsciiSet, NON_ALPHANUMERIC, utf8_percent_encode};
use rust_team_data::v1::{BASE_URL, Team, TeamKind, TeamMember, Teams};
use rust_team_data::v1::{BASE_URL, People, Person, Team, TeamKind, TeamMember, Teams};
use serde::Serialize;
use std::cmp::Reverse;
use std::collections::HashMap;
Expand Down Expand Up @@ -49,17 +49,20 @@ pub fn encode_zulip_stream(
}

#[derive(Debug, Clone)]
pub struct RustTeams {
pub struct RustTeamData {
pub teams: Vec<Team>,
pub archived_teams: Vec<Team>,
// GitHub username => person data
pub people: HashMap<String, Person>,
}

impl RustTeams {
impl RustTeamData {
#[cfg(test)]
fn dummy(teams: Vec<Team>) -> Self {
RustTeams {
RustTeamData {
teams,
archived_teams: vec![],
people: HashMap::new(),
}
}

Expand Down Expand Up @@ -277,16 +280,21 @@ impl RustTeams {

fn add_team(
people: &mut HashMap<String, PersonData>,
ctx: &RustTeams,
ctx: &RustTeamData,
member: &TeamMember,
team: &Team,
mode: TeamMode,
) {
let person_team_data = ctx
.people
.get(&member.github)
.unwrap_or_else(|| panic!("Person {} not found in people.json", member.github));
let person = people
.entry(member.github.clone())
.or_insert_with(move || PersonData {
name: member.name.clone(),
github: member.github.clone(),
github_sponsors: person_team_data.github_sponsors,
active_teams: vec![],
alumni_teams: vec![],
});
Expand Down Expand Up @@ -463,15 +471,16 @@ impl PersonTeam {
pub struct PersonData {
name: String,
pub github: String,
github_sponsors: bool,
active_teams: Vec<PersonTeam>,
alumni_teams: Vec<PersonTeam>,
}

pub fn load_rust_teams() -> anyhow::Result<RustTeams> {
pub fn load_rust_teams() -> anyhow::Result<RustTeamData> {
println!("Downloading Team API data");

// Parallelize the download to make website build faster
let (teams, archived_teams) = std::thread::scope(|scope| {
let (teams, archived_teams, people) = std::thread::scope(|scope| {
let teams = scope.spawn(|| -> anyhow::Result<Teams> {
let response = fetch(&format!("{BASE_URL}/teams.json"))?;
Ok(serde_json::from_str(&response)?)
Expand All @@ -480,13 +489,22 @@ pub fn load_rust_teams() -> anyhow::Result<RustTeams> {
let response = fetch(&format!("{BASE_URL}/archived-teams.json"))?;
Ok(serde_json::from_str(&response)?)
});
(teams.join().unwrap(), archived_teams.join().unwrap())
let people = scope.spawn(|| -> anyhow::Result<People> {
let response = fetch(&format!("{BASE_URL}/people.json"))?;
Ok(serde_json::from_str(&response)?)
});
(
teams.join().unwrap(),
archived_teams.join().unwrap(),
people.join().unwrap(),
)
});
let (teams, archived_teams) = (teams?, archived_teams?);
let (teams, archived_teams, people) = (teams?, archived_teams?, people?);

Ok(RustTeams {
Ok(RustTeamData {
teams: teams.teams.into_values().collect(),
archived_teams: archived_teams.teams.into_values().collect(),
people: people.people.into_iter().collect(),
})
}

Expand Down Expand Up @@ -517,7 +535,7 @@ impl fmt::Display for TeamNotFound {

#[cfg(test)]
mod tests {
use super::{RustTeams, TeamNotFound};
use super::{RustTeamData, TeamNotFound};
use rust_team_data::v1::{Team, TeamKind, TeamMember, TeamWebsite};

fn dummy_team(name: &str) -> Team {
Expand Down Expand Up @@ -569,7 +587,7 @@ mod tests {
fn test_index_data() {
let mut foo = dummy_team("foo");
foo.kind = TeamKind::WorkingGroup;
let data = RustTeams::dummy(vec![foo, dummy_team("bar")]);
let data = RustTeamData::dummy(vec![foo, dummy_team("bar")]);

let res = data.index_data();
assert_eq!(res.teams.len(), 1);
Expand All @@ -581,7 +599,7 @@ mod tests {
fn test_index_subteams_are_hidden() {
let mut foo = dummy_team("foo");
foo.subteam_of = Some(String::new());
let data = RustTeams::dummy(vec![foo]);
let data = RustTeamData::dummy(vec![foo]);

assert_eq!(data.index_data().teams.len(), 0);
}
Expand All @@ -606,7 +624,7 @@ mod tests {
other_wg.subteam_of = Some("other".into());
other_wg.kind = TeamKind::WorkingGroup;

let data = RustTeams::dummy(vec![
let data = RustTeamData::dummy(vec![
main,
subteam,
subteam2,
Expand Down Expand Up @@ -635,7 +653,7 @@ mod tests {
let foo = dummy_team("foo");
let mut bar = dummy_team("bar");
bar.kind = TeamKind::WorkingGroup;
let data = RustTeams::dummy(vec![foo, bar]);
let data = RustTeamData::dummy(vec![foo, bar]);

assert!(
data.clone()
Expand Down Expand Up @@ -663,7 +681,7 @@ mod tests {
fn test_subteams_cant_be_loaded() {
let mut foo = dummy_team("foo");
foo.subteam_of = Some("bar".into());
let data = RustTeams::dummy(vec![foo, dummy_team("bar")]);
let data = RustTeamData::dummy(vec![foo, dummy_team("bar")]);

assert!(
data.page_data("teams", "foo")
Expand Down
13 changes: 9 additions & 4 deletions templates/governance/person.html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

{{#*inline "page"}}
<section class="green" style="padding-bottom: 10px;">
<div class="w-100 mw-none mw-8-m mw9-l center f1">
<div class="w-100 mw-none mw-8-m mw9-l center f1 ph3 flex flex-column flex-row-l items-end-l justify-between">
<div class="w-100 w-50-l mb3 flex flex-row items-start">
<a class="mr4 w5 h5 flex-shrink-0" href="https://github.com/{{data.github}}">
<a class="mr4 w4 h4 w5-l h5-l flex-shrink-0" href="https://github.com/{{data.github}}">
<img class="w-100 h-100 bg-white br2"
src="https://avatars.githubusercontent.com/{{data.github}}"
alt="{{data.name}}">
Expand All @@ -34,12 +34,17 @@
</div>
</div>
</div>
<div class="f3">
{{# if data.github_sponsors }}
<a href="https://github.com/sponsors/{{data.github}}" class="button button-secondary mw6">Sponsor {{ data.name }} on GitHub</a>
{{/if}}
</div>
</div>
</section>

{{# if data.active_teams }}
<section class="purple" style="padding-bottom: 10px;">
<div class="w-100 mw-none mw-8-m mw9-l center">
<div class="w-100 mw-none mw-8-m mw9-l center ph3">
<header>
<h2>{{ fluent "governance-person-team-member" }}</h2>
<div class="highlight"></div>
Expand All @@ -53,7 +58,7 @@

{{# if data.alumni_teams }}
<section class="red" style="padding-bottom: 10px;">
<div class="w-100 mw-none mw-8-m mw9-l center">
<div class="w-100 mw-none mw-8-m mw9-l center ph3">
<header>
<h2>{{ fluent "governance-person-team-alumni" }}</h2>
<div class="highlight"></div>
Expand Down