Skip to content

Commit

Permalink
fix nearby task looping too hard tasks issue
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Apr 9, 2024
1 parent 49bffd1 commit d06abe3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/org/maproulette/models/dal/TaskDAL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,16 @@ class TaskDAL @Inject() (
case None => ""
}

val query = s"$select ${queryBuilder.toString} ${whereClause.toString} " +
s"ORDER BY $proximityOrdering tasks.status, RANDOM() LIMIT ${this.sqlLimit(limit)}"
val query =
s"""$select ${queryBuilder.toString} ${whereClause.toString}
|ORDER BY
| (CASE
| WHEN tasks.status = ${Task.STATUS_TOO_HARD} AND tasks.completed_by = ${user.id} THEN 0
| WHEN tasks.status = ${Task.STATUS_SKIPPED} AND tasks.completed_by = ${user.id} THEN 1
| ELSE 2
| END) DESC,
| $proximityOrdering tasks.status, RANDOM() LIMIT ${this
.sqlLimit(limit)}""".stripMargin

implicit val ids = List[Long]()
this.cacheManager.withIDListCaching { implicit cachedItems =>
Expand Down

0 comments on commit d06abe3

Please sign in to comment.