Skip to content

Commit

Permalink
fix nearby task looping too hard tasks issue (#1110)
Browse files Browse the repository at this point in the history
* fix nearby task looping too hard tasks issue

* make the hour interval base on the modified column instead of the created column.

* set skipped tasks and too hard tasks set by the user as the last tasks to be selected

* simplify conditions
  • Loading branch information
CollinBeczak committed May 12, 2024
1 parent c61da90 commit 70416fe
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions app/org/maproulette/models/dal/TaskDAL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,17 @@ class TaskDAL @Inject() (
case Failure(f) => List.empty
}
if (mediumPriorityTasks.isEmpty) {
this.getRandomTasks(user, params, limit, Some(Challenge.PRIORITY_LOW), proximityId)
val lowPriorityTasks = Try(
this.getRandomTasks(user, params, limit, Some(Challenge.PRIORITY_LOW), proximityId)
) match {
case Success(res) => res
case Failure(f) => List.empty
}
if (lowPriorityTasks.isEmpty) {
this.getRandomTasks(user, params, limit, None, proximityId)
} else {
lowPriorityTasks
}
} else {
mediumPriorityTasks
}
Expand Down Expand Up @@ -1148,8 +1158,12 @@ class TaskDAL @Inject() (
)

priority match {
case Some(p) => appendInWhereClause(whereClause, s"tasks.priority = $p")
case None => //Ignore
case Some(p) =>
appendInWhereClause(
whereClause,
s"tasks.priority = $p AND (tasks.completed_by != ${user.id} OR tasks.completed_by IS NULL)"
)
case None => // Ignore
}

if (taskTagIds.nonEmpty) {
Expand Down

0 comments on commit 70416fe

Please sign in to comment.