Skip to content

Commit

Permalink
Getting minimum number of problems
Browse files Browse the repository at this point in the history
  • Loading branch information
YoussifHassan8 committed Aug 8, 2024
1 parent 74b7a35 commit 2dd002e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ async function get_problems() {

available_problems = shuffle(available_problems);

if (available_problems.length < problems_cnt) {
if (available_problems.length === 0) {
Swal.fire({
icon: "error",
title: "Oops...",
Expand All @@ -434,8 +434,14 @@ async function get_problems() {

return false;
}

let final_problems = available_problems.slice(0, problems_cnt);
if (available_problems.length < problems_cnt) {
Swal.fire({
icon: "warning",
title: "Limited Results",
text: `Only ${available_problems.length} problems are available, but you requested ${problems_cnt} problems. Please adjust your filters or check back later.`,
});
}

return final_problems;
}
Expand Down

0 comments on commit 2dd002e

Please sign in to comment.