From 29c118c3239bc1e21d8a864903bcd9234a0fb04f Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Fri, 9 Aug 2024 16:58:10 -0500 Subject: [PATCH] add more descriptions and simplify queries and parses --- app/org/maproulette/framework/model/LockedTask.scala | 7 ++++++- .../repository/UserSavedObjectsRepository.scala | 4 ++-- conf/v2_route/user.api | 10 ++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/org/maproulette/framework/model/LockedTask.scala b/app/org/maproulette/framework/model/LockedTask.scala index b7b99a93..03d15e4e 100644 --- a/app/org/maproulette/framework/model/LockedTask.scala +++ b/app/org/maproulette/framework/model/LockedTask.scala @@ -11,11 +11,16 @@ import play.api.libs.json.JodaReads._ /** * Mapping of object structure for fetching task lock data + * + * id - A database assigned id for the Task + * parent - The id of the challenge of the locked task + * parentName - The name of the challenge of the locked task + * startedAt - The time that the task was locked */ case class LockedTaskData( id: Long, parent: Long, - parentName: Option[String], + parentName: String, startedAt: DateTime ) diff --git a/app/org/maproulette/framework/repository/UserSavedObjectsRepository.scala b/app/org/maproulette/framework/repository/UserSavedObjectsRepository.scala index 5afcd163..3132baf1 100644 --- a/app/org/maproulette/framework/repository/UserSavedObjectsRepository.scala +++ b/app/org/maproulette/framework/repository/UserSavedObjectsRepository.scala @@ -167,7 +167,7 @@ class UserSavedObjectsRepository @Inject() ( val parser = for { id <- get[Long]("id") parent <- get[Long]("tasks.parent_id") - parentName <- get[Option[String]]("challenges.challenge_name") + parentName <- get[String]("challenges.challenge_name") lockedTime <- get[DateTime]("locked.locked_time") } yield (LockedTaskData(id, parent, parentName, lockedTime)) @@ -175,7 +175,7 @@ class UserSavedObjectsRepository @Inject() ( SELECT t.id, t.parent_id, l.locked_time, c.name AS challenge_name FROM tasks t INNER JOIN locked l ON t.id = l.item_id - LEFT JOIN challenges c ON t.parent_id = c.id + INNER JOIN challenges c ON t.parent_id = c.id WHERE l.user_id = {userId} LIMIT {limit} """ diff --git a/conf/v2_route/user.api b/conf/v2_route/user.api index 2eb0feaf..8a1230a5 100644 --- a/conf/v2_route/user.api +++ b/conf/v2_route/user.api @@ -331,9 +331,11 @@ GET /user/:userId/savedTasks @org.maproulette.framework.c # schema: # type: array # items: -# $ref: '#/components/schemas/org.maproulette.framework.model.Task' +# $ref: '#/components/schemas/org.maproulette.framework.model.LockedTask' # '401': -# description: The user is not authorized to make this request +# description: The user is not authorized to make this request. +# '404': +# description: If User or Task for provided ID's is not found. # parameters: # - name: userId # in: path @@ -341,6 +343,10 @@ GET /user/:userId/savedTasks @org.maproulette.framework.c # - name: limit # in: query # description: Limit the number of results returned in the response. Default value is 50. +# required: false +# schema: +# type: integer +# default: 50 ### GET /user/:userId/lockedTasks @org.maproulette.framework.controller.UserController.getLockedTasks(userId:Long, limit:Int ?= 50) ###