Skip to content

Commit

Permalink
revert task locking on fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Mar 11, 2024
1 parent 4b90bc7 commit f77451d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ class TaskBundleController @Inject() (
* @param id The id for the bundle
* @return Task Bundle
*/
def getTaskBundle(id: Long, lockTasks: Boolean): Action[AnyContent] = Action.async {
def getTaskBundle(id: Long): Action[AnyContent] = Action.async {
implicit request =>
this.sessionManager.authenticatedRequest { implicit user =>
Ok(Json.toJson(this.serviceManager.taskBundle.getTaskBundle(user, id, lockTasks)))
Ok(Json.toJson(this.serviceManager.taskBundle.getTaskBundle(user, id)))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,21 +418,4 @@ class TaskBundleRepository @Inject() (
""").as(this.getTaskParser(this.taskRepository.updateAndRetrieve).*)
}
}

/**
* Fetches a list of tasks associated with the given bundle id.
*
* @param bundleId The id of the bundle
*/
def lockBundledTasks(user: User, tasks: List[Task]) = {
this.withMRConnection { implicit c =>
for (task <- tasks) {
try {
this.lockItem(user, task)
} catch {
case e: Exception => this.logger.warn(e.getMessage)
}
}
}
}
}
13 changes: 6 additions & 7 deletions app/org/maproulette/framework/service/TaskBundleService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class TaskBundleService @Inject() (
*
* @param bundleId The id of the bundle
*/
def getTaskBundle(user: User, bundleId: Long, lockTasks: Boolean = false): TaskBundle = {
def getTaskBundle(user: User, bundleId: Long): TaskBundle = {
val filterQuery =
Query.simple(
List(
Expand All @@ -157,13 +157,12 @@ class TaskBundleService @Inject() (
val ownerId = this.repository.retrieveOwner(filterQuery)
val tasks = this.repository.retrieveTasks(filterQuery)

if (ownerId.isEmpty) {
throw new NotFoundException(s"Task Bundle not found with id $bundleId.")
}
if (lockTasks) {
this.repository.lockBundledTasks(user, tasks)
if (ownerId == None) {
throw new NotFoundException(s"Task Bundle not found with id ${bundleId}.")
}

TaskBundle(bundleId, ownerId.get, tasks.map(_.id), Some(tasks))
TaskBundle(bundleId, ownerId.get, tasks.map(task => {
task.id
}), Some(tasks))
}
}
5 changes: 1 addition & 4 deletions conf/v2_route/bundle.api
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ POST /taskBundle @org.maproulette.framework.c
# in: path
# description: The id of the Task Bundle
# required: true
# - name: lockTasks
# in: query
# description: The tasks in the bundle will be locked by the user.
###
GET /taskBundle/:id @org.maproulette.framework.controller.TaskBundleController.getTaskBundle(id:Long, lockTasks:Boolean ?= false)
GET /taskBundle/:id @org.maproulette.framework.controller.TaskBundleController.getTaskBundle(id:Long)
###
# tags: [ Bundle ]
# summary: Resets a Task Bundle
Expand Down

0 comments on commit f77451d

Please sign in to comment.