Skip to content

Commit

Permalink
replace pointer with new refined marker parser
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Jun 3, 2024
1 parent 23d73db commit c189159
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class TaskClusterRepository @Inject() (override val db: Database, challengeDAL:

val DEFAULT_NUMBER_OF_POINTS = 100

val pointParser = this.challengeDAL.pointParser
val pointParser = this.challengeDAL.pointParser
val markerParser = this.challengeDAL.markerParser

private val joinClause =
new StringBuilder(
Expand Down Expand Up @@ -195,22 +196,15 @@ class TaskClusterRepository @Inject() (override val db: Database, challengeDAL:
query
.build(
s"""
SELECT tasks.id, tasks.name, tasks.parent_id, c.name, tasks.instruction, tasks.status, tasks.mapped_on,
tasks.completed_time_spent, tasks.completed_by,
tasks.bundle_id, tasks.is_bundle_primary, tasks.cooperative_work_json::TEXT as cooperative_work,
task_review.review_status, task_review.review_requested_by, task_review.reviewed_by, task_review.reviewed_at,
task_review.review_started_at, task_review.meta_review_status, task_review.meta_reviewed_by,
task_review.meta_reviewed_at, task_review.additional_reviewers,
ST_AsGeoJSON(tasks.location) AS location, priority,
CASE WHEN task_review.review_started_at IS NULL
THEN 0
ELSE EXTRACT(epoch FROM (task_review.reviewed_at - task_review.review_started_at)) END
AS reviewDuration
FROM tasks
${joinClause.toString()}
"""
SELECT tasks.id, tasks.name, tasks.parent_id, c.name, tasks.status,
tasks.bundle_id, tasks.is_bundle_primary,
task_review.review_status, task_review.meta_review_status,
ST_AsGeoJSON(tasks.location) AS location, priority
FROM tasks
${joinClause.toString()}
"""
)
.as(this.pointParser.*)
.as(this.markerParser.*)

(count, Some(results))
} else {
Expand Down
58 changes: 58 additions & 0 deletions app/org/maproulette/models/dal/ChallengeDAL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,64 @@ class ChallengeDAL @Inject() (
}
}

val markerParser: RowParser[ClusteredPoint] = {
get[Long]("tasks.id") ~
get[String]("tasks.name") ~
get[Long]("tasks.parent_id") ~
get[String]("challenges.name").? ~
get[String]("challengeName").? ~
get[String]("location") ~
get[Int]("tasks.status") ~
get[Int]("tasks.priority") ~
get[Option[Long]]("tasks.bundle_id") ~
get[Option[Boolean]]("tasks.is_bundle_primary") ~
get[Option[Int]]("task_review.review_status") ~
get[Option[Int]]("task_review.meta_review_status") map {
case id ~ name ~ parentId ~ parentName ~ orParentName ~ location ~ status ~
priority ~ bundleId ~
isBundlePrimary ~ reviewStatus ~
metaReviewStatus =>
val locationJSON = Json.parse(location)
val coordinates = (locationJSON \ "coordinates").as[List[Double]]
val point = Point(coordinates(1), coordinates.head)
val pointReview =
PointReview(
reviewStatus,
None,
None,
None,
metaReviewStatus,
None,
None,
None,
None
)
ClusteredPoint(
id,
-1,
"",
name,
parentId,
parentName.getOrElse(orParentName.get),
point,
JsString(""),
"",
DateTime.now(),
-1,
Actions.ITEM_TYPE_TASK,
status,
None,
None,
None,
None,
pointReview,
priority,
bundleId,
isBundlePrimary
)
}
}

private val DEFAULT_NUM_CHILDREN_LIST = 1000

/**
Expand Down

0 comments on commit c189159

Please sign in to comment.