Skip to content

Commit eb1a8dd

Browse files
Merge pull request #787 from fee1-dead-contrib/add_email
Generate information about people in teams API
2 parents 001e637 + c82a09e commit eb1a8dd

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed

rust_team_data/src/v1.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,16 @@ pub struct Branch {
176176
pub ci_checks: Vec<String>,
177177
pub dismiss_stale_review: bool,
178178
}
179+
180+
#[derive(Debug, Clone, Serialize, Deserialize)]
181+
pub struct Person {
182+
pub name: String,
183+
pub email: Option<String>,
184+
pub github_id: usize,
185+
}
186+
187+
#[derive(Debug, Clone, Serialize, Deserialize)]
188+
pub struct People {
189+
/// GitHub name as key.
190+
pub people: IndexMap<String, Person>,
191+
}

src/static_api.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::data::Data;
2-
use crate::schema::{Bot, Permissions, RepoPermission, TeamKind, ZulipGroupMember};
2+
use crate::schema::{Bot, Email, Permissions, RepoPermission, TeamKind, ZulipGroupMember};
33
use failure::Error;
44
use indexmap::IndexMap;
55
use log::info;
@@ -29,6 +29,7 @@ impl<'a> Generator<'a> {
2929
self.generate_permissions()?;
3030
self.generate_rfcbot()?;
3131
self.generate_zulip_map()?;
32+
self.generate_people()?;
3233
Ok(())
3334
}
3435

@@ -306,6 +307,30 @@ impl<'a> Generator<'a> {
306307
Ok(())
307308
}
308309

310+
fn generate_people(&self) -> Result<(), Error> {
311+
let mut people = IndexMap::new();
312+
313+
for person in self.data.people() {
314+
people.insert(
315+
person.github().into(),
316+
v1::Person {
317+
name: person.name().into(),
318+
email: match person.email() {
319+
Email::Missing | Email::Disabled => None,
320+
Email::Present(s) => Some(s.into()),
321+
},
322+
github_id: person.github_id(),
323+
},
324+
);
325+
}
326+
327+
people.sort_keys();
328+
329+
self.add("v1/people.json", &v1::People { people })?;
330+
331+
Ok(())
332+
}
333+
309334
fn add<T: serde::Serialize>(&self, path: &str, obj: &T) -> Result<(), Error> {
310335
info!("writing API object {}...", path);
311336
let dest = self.dest.join(path);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"people": {
3+
"user-0": {
4+
"name": "Zeroth user",
5+
"email": "user0@example.com",
6+
"github_id": 0
7+
},
8+
"user-1": {
9+
"name": "First user",
10+
"email": "user1@example.com",
11+
"github_id": 0
12+
},
13+
"user-2": {
14+
"name": "Second user",
15+
"email": "user2@example.com",
16+
"github_id": 2
17+
},
18+
"user-3": {
19+
"name": "Third user",
20+
"email": "user3@example.com",
21+
"github_id": 3
22+
},
23+
"user-4": {
24+
"name": "Fourth user",
25+
"email": "user4@example.com",
26+
"github_id": 4
27+
},
28+
"user-5": {
29+
"name": "Fifth user",
30+
"email": "user5@example.com",
31+
"github_id": 5
32+
},
33+
"user-6": {
34+
"name": "Sixth user",
35+
"email": "user6@example.com",
36+
"github_id": 6
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)