Skip to content

Commit

Permalink
fix(informative reports): account for size
Browse files Browse the repository at this point in the history
  • Loading branch information
hackermondev committed Jan 31, 2025
1 parent 14f68ae commit cbf9721
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/security_discord/src/subscriptions/informative_reports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ fn build_embed_data(
let users = if users.len() == 1 {
&users[0]
} else if users.len() <= 5 {
let four_users = &users[..3].join(", ");
let last_users = &users[4];
&format!("{four_users} and {last_users}")
let oxford_cutoff = users.len() - 1;
let last = &users[oxford_cutoff];
let oxford_cutoff = &users[..oxford_cutoff].join(", ");
&format!("{oxford_cutoff} and {last}")
} else {
let five_users = &users[..3].join(", ");
let remaining_count = users[3..].len();
let five_users = &users[..5].join(", ");
let remaining_count = users[5..].len();
let plural = remaining_count > 1;

if plural {
Expand Down

0 comments on commit cbf9721

Please sign in to comment.