From f77451d25e2d5696d08b6214e38cffe4a89f260c Mon Sep 17 00:00:00 2001 From: CollinBeczak Date: Mon, 11 Mar 2024 15:23:07 -0500 Subject: [PATCH] revert task locking on fetch --- .../controller/TaskBundleController.scala | 4 ++-- .../repository/TaskBundleRepository.scala | 17 ----------------- .../framework/service/TaskBundleService.scala | 13 ++++++------- conf/v2_route/bundle.api | 5 +---- 4 files changed, 9 insertions(+), 30 deletions(-) diff --git a/app/org/maproulette/framework/controller/TaskBundleController.scala b/app/org/maproulette/framework/controller/TaskBundleController.scala index effd945a..91e86f44 100644 --- a/app/org/maproulette/framework/controller/TaskBundleController.scala +++ b/app/org/maproulette/framework/controller/TaskBundleController.scala @@ -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))) } } diff --git a/app/org/maproulette/framework/repository/TaskBundleRepository.scala b/app/org/maproulette/framework/repository/TaskBundleRepository.scala index 76a2fac5..4166d2a8 100644 --- a/app/org/maproulette/framework/repository/TaskBundleRepository.scala +++ b/app/org/maproulette/framework/repository/TaskBundleRepository.scala @@ -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) - } - } - } - } } diff --git a/app/org/maproulette/framework/service/TaskBundleService.scala b/app/org/maproulette/framework/service/TaskBundleService.scala index a5d746f2..df6827a9 100644 --- a/app/org/maproulette/framework/service/TaskBundleService.scala +++ b/app/org/maproulette/framework/service/TaskBundleService.scala @@ -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( @@ -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)) } } diff --git a/conf/v2_route/bundle.api b/conf/v2_route/bundle.api index e6841b55..f68b7409 100644 --- a/conf/v2_route/bundle.api +++ b/conf/v2_route/bundle.api @@ -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