Skip to content

Commit

Permalink
Fix deduplication
Browse files Browse the repository at this point in the history
  • Loading branch information
byte-sized-emi committed Feb 10, 2024
1 parent 687e55d commit c72b1e9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/bot/commands/subject.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! TODO: Permissions
use std::collections::HashSet;

use futures::future::join_all;
use poise::serenity_prelude::{GuildId, RoleId};
use sqlx::{MySql, Pool};
Expand Down Expand Up @@ -154,11 +156,11 @@ async fn get_available_subjects(

let subjects = join_all(subjects).await;

let flattened_subjects: Vec<DatabaseSubject> = subjects.iter()
.flatten().flatten().cloned().dedup()
.collect();

flattened_subjects
subjects.iter()
.flatten().flatten().cloned()
.sorted_by_key(|subject| subject.id)
.dedup()
.collect()
}

/// Parses subject names/ids from user input, then
Expand Down

0 comments on commit c72b1e9

Please sign in to comment.