diff --git a/app/org/maproulette/framework/mixins/TaskParserMixin.scala b/app/org/maproulette/framework/mixins/TaskParserMixin.scala index b1179cc8..ee5de80a 100644 --- a/app/org/maproulette/framework/mixins/TaskParserMixin.scala +++ b/app/org/maproulette/framework/mixins/TaskParserMixin.scala @@ -114,6 +114,7 @@ trait TaskParserMixin { Option[String] ) ): RowParser[TaskWithReview] = { + // tasks fields get[Long]("tasks.id") ~ get[String]("tasks.name") ~ get[DateTime]("tasks.created") ~ @@ -127,6 +128,12 @@ trait TaskParserMixin { get[Option[DateTime]]("tasks.mapped_on") ~ get[Option[Long]]("tasks.completed_time_spent") ~ get[Option[Long]]("tasks.completed_by") ~ + get[Int]("tasks.priority") ~ + get[Option[Long]]("tasks.changeset_id") ~ + get[Option[Long]]("tasks.bundle_id") ~ + get[Option[Boolean]]("tasks.is_bundle_primary") ~ + get[Option[String]]("responses") ~ + // task_review fields get[Option[Int]]("task_review.review_status") ~ get[Option[Long]]("task_review.review_requested_by") ~ get[Option[Long]]("task_review.reviewed_by") ~ @@ -139,21 +146,20 @@ trait TaskParserMixin { get[Option[DateTime]]("task_review.review_claimed_at") ~ get[Option[List[Long]]]("task_review.additional_reviewers") ~ get[Option[String]]("task_review.error_tags") ~ - get[Int]("tasks.priority") ~ - get[Option[Long]]("tasks.changeset_id") ~ - get[Option[Long]]("tasks.bundle_id") ~ - get[Option[Boolean]]("tasks.is_bundle_primary") ~ + // challenges and projects fields get[Option[String]]("challenge_name") ~ get[Option[String]]("project_name") ~ + // users fields get[Option[String]]("review_requested_by_username") ~ - get[Option[String]]("reviewed_by_username") ~ - get[Option[String]]("responses") map { + get[Option[String]]("reviewed_by_username") map { case id ~ name ~ created ~ modified ~ parent_id ~ instruction ~ location ~ status ~ geojson ~ - cooperativeWork ~ mappedOn ~ completedTimeSpent ~ completedBy ~ reviewStatus ~ reviewRequestedBy ~ + cooperativeWork ~ mappedOn ~ completedTimeSpent ~ completedBy ~ + priority ~ changesetId ~ bundleId ~ isBundlePrimary ~ responses ~ + reviewStatus ~ reviewRequestedBy ~ reviewedBy ~ reviewedAt ~ metaReviewedBy ~ metaReviewStatus ~ metaReviewedAt ~ reviewStartedAt ~ reviewClaimedBy ~ reviewClaimedAt ~ additionalReviewers ~ errorTags ~ - priority ~ changesetId ~ bundleId ~ isBundlePrimary ~ challengeName ~ projectName ~ - reviewRequestedByUsername ~ reviewedByUsername ~ responses => + challengeName ~ projectName ~ + reviewRequestedByUsername ~ reviewedByUsername => val values = updateAndRetrieve(id, geojson, location, cooperativeWork) TaskWithReview( Task( diff --git a/app/org/maproulette/framework/repository/TaskReviewRepository.scala b/app/org/maproulette/framework/repository/TaskReviewRepository.scala index f0713f7e..8de3d9f9 100644 --- a/app/org/maproulette/framework/repository/TaskReviewRepository.scala +++ b/app/org/maproulette/framework/repository/TaskReviewRepository.scala @@ -480,19 +480,27 @@ class TaskReviewRepository @Inject() ( .build( s""" SELECT + -- tasks fields tasks.id, tasks.name, tasks.created, tasks.modified, tasks.parent_id, tasks.instruction, - NULL AS geo_location, + ST_AsGeoJSON(tasks.location) AS geo_location, tasks.status, - NULL AS geo_json, - NULL AS cooperative_work, + tasks.geojson::TEXT AS geo_json, + tasks.cooperative_work_json::TEXT AS cooperative_work, tasks.mapped_on, tasks.completed_time_spent, tasks.completed_by, + tasks.priority, + tasks.changeset_id, + tasks.bundle_id, + tasks.is_bundle_primary, + tasks.completion_responses::TEXT AS responses, + + -- task_review fields task_review.review_status, task_review.review_requested_by, task_review.reviewed_by, @@ -505,22 +513,26 @@ class TaskReviewRepository @Inject() ( task_review.review_claimed_at, task_review.additional_reviewers, task_review.error_tags, - tasks.priority, - tasks.changeset_id, - tasks.bundle_id, - tasks.is_bundle_primary, + + -- challenges and projects fields c.name AS challenge_name, p.display_name AS project_name, + + -- users fields mappers.name AS review_requested_by_username, - reviewers.name AS reviewed_by_username, - NULL AS responses - FROM - tasks - INNER JOIN task_review ON task_review.task_id = tasks.id - LEFT OUTER JOIN users mappers ON task_review.review_requested_by = mappers.id - LEFT OUTER JOIN users reviewers ON task_review.reviewed_by = reviewers.id - INNER JOIN challenges c ON c.id = tasks.parent_id - INNER JOIN projects p ON p.id = c.parent_id + reviewers.name AS reviewed_by_username + + FROM tasks + -- Joining with task_review + INNER JOIN task_review ON task_review.task_id = tasks.id + + -- Joining with challenges and projects + INNER JOIN challenges c ON c.id = tasks.parent_id + INNER JOIN projects p ON p.id = c.parent_id + + -- Joining with users + LEFT OUTER JOIN users mappers ON task_review.review_requested_by = mappers.id + LEFT OUTER JOIN users reviewers ON task_review.reviewed_by = reviewers.id """ ) .as(reviewParser.*)