Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
apiraino committed Sep 30, 2023
1 parent ce8b243 commit 5d9e2d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
12 changes: 5 additions & 7 deletions pr_prefs_backoffice.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ This backoffice will set one cookie (`triagebot.session`) to understand if a use

Access authorization is handled by GitHub, so users will need to be logged in GitHub and authorize this Github Application.

Access to this backoffice is granted only to GitHub users that are members of a Rust project team (teams are defined [here](https://github.com/rust-lang/team/tree/HEAD/teams)). Only specific Rust teams are allowed to use
this backoffice (mostly for testing purposes, to switch users to the new workflow slowly). Teams allowed are defined in the env var `NEW_PR_ASSIGNMENT_TEAMS` (see `.env.sample`).
Access to this backoffice is granted only to GitHub users that are members of a Rust project team (teams are defined [here](https://github.com/rust-lang/team/tree/HEAD/teams)). Only specific Rust teams are allowed to use this backoffice (mostly for testing purposes, to gradually onboard users to the new workflow). Teams allowed are defined in the env var `NEW_PR_ASSIGNMENT_TEAMS` (see `.env.sample`).

Teams members are expected to set their own review preferences using this backoffice. In case a team member didn't yet set their own preferences, these defaults will be applied:
- Max 5 pull requests assigned (see constant `PREF_MAX_ASSIGNED_PRS`)
- 20 days before a notification is sent for a pull request assigned that is waiting for review (see constant `PREF_ALLOW_PING_AFTER_DAYS`)
- 15 days before a notification is sent for a pull request assigned that is waiting for review (see constant `PREF_ALLOW_PING_AFTER_DAYS`)

## How to locally run this backoffice

Expand All @@ -31,10 +30,9 @@ Teams members are expected to set their own review preferences using this backof

## TODO

- [ ] Build some tooling to import members from a team `.toml` file (SQL fixtures, CLI, or else)
- [ ] Set some defaults in the DB table structure for contributors that did not set any for themselves.
- [ ] Handle cleanup of the preferences DB table for team members not existing anymore in the teams .toml: delete their assignments, PRs go back to the pool of those needing an assignee
- [ ] Cache somehow teams .toml download from github to avoid retrieving those `.toml` files too often
- [x] Build some tooling to import members from teams
- [x] Set some defaults in the DB table structure for contributors that did not set any for themselves.
- [ ] Handle cleanup of the preferences DB table for team members not existing anymore (or were moved to "alumni") in the teams: delete their assignments, PRs go back to the pool of those needing an assignee
- [ ] maybe more input validation, see `validate_data()` in `./src/main.rs`
- [ ] Now we are handling contributors workload for a single team. Some contributors work across teams. Make this backoffice aware of other teams and show the actual workload of contributors

Expand Down
21 changes: 7 additions & 14 deletions src/bin/import-users-from-github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@ use triagebot::github::User;
use triagebot::handlers::review_prefs::{add_prefs, delete_prefs, get_prefs};
use triagebot::{db::make_client, github};

// - 1. Download the teams and retrieve those listed in $NEW_PR_ASSIGNMENT_TEAMS
// - 2. match the team `people.members` with the table `users` and `review_capacity`
// - 3. Follow this scheme to perform a sync

// | - | triagebot.users | triagebot.review_capacity | action |
// |-------|-----------------|---------------------------|---------------------------------------|
// | V | V | X | add |
// | V | X | X | add |
// | V | X | V | add |
// | X | V | X | do nothing |
// | X | X | V | remove from triagebot.review_capacity |
// Import and synchronization:
// 1. Download teams and retrieve those listed in $NEW_PR_ASSIGNMENT_TEAMS
// 2. Add missing team members to the review preferences table
// 3. Delete preferences for members not present in the team roster anymore

#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -43,7 +36,7 @@ async fn main() -> anyhow::Result<()> {
.collect::<Vec<_>>();
debug!("Team {} members loaded: {:?}", team, team_members);

// 2. get team members review capacity
// get team members review capacity
let team_review_prefs = get_prefs(
&db_client,
&team_members
Expand All @@ -55,7 +48,7 @@ async fn main() -> anyhow::Result<()> {
)
.await;

// 3. Add missing team members to the review preferences table
// 2. Add missing team members to the review preferences table
for member in &team_members {
if !team_review_prefs
.iter()
Expand Down Expand Up @@ -84,7 +77,7 @@ async fn main() -> anyhow::Result<()> {
}
}

// 4. delete prefs for members not present in the team roster anymore
// 3. delete prefs for members not present in the team roster anymore
let removed_members = team_review_prefs
.iter()
.filter(|tm| {
Expand Down

0 comments on commit 5d9e2d5

Please sign in to comment.