Skip to content

Commit

Permalink
add more descriptions and simplify queries and parses
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Aug 9, 2024
1 parent 9018008 commit 29c118c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/org/maproulette/framework/model/LockedTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ 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))

val query = """
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}
"""
Expand Down
10 changes: 8 additions & 2 deletions conf/v2_route/user.api
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,22 @@ 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
# description: The id of the user to retrieve the locked tasks for
# - 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)
###
Expand Down

0 comments on commit 29c118c

Please sign in to comment.