Skip to content

Commit

Permalink
add dataset_url to challenge table
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwarz2030 committed Nov 5, 2024
1 parent 3126e0a commit fa34a32
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/org/maproulette/framework/model/Challenge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ case class ChallengeExtra(
isArchived: Boolean = false,
reviewSetting: Int = Challenge.REVIEW_SETTING_NOT_REQUIRED,
taskWidgetLayout: Option[JsValue] = None,
datasetUrl: Option[String] = None,
systemArchivedAt: Option[DateTime] = None,
presets: Option[List[String]] = None
presets: Option[List[String]] = None,
) extends DefaultWrites

case class ChallengeListing(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ object ChallengeRepository {
get[Option[List[Long]]]("virtual_parent_ids") ~
get[Boolean]("challenges.is_archived") ~
get[Int]("challenges.review_setting") ~
get[Option[String]]("challenges.dataset_url") ~
get[Option[JsValue]]("challenges.task_widget_layout") ~
get[Option[DateTime]]("challenges.system_archived_at") map {
case id ~ name ~ created ~ modified ~ description ~ infoLink ~ ownerId ~ parentId ~ instruction ~
Expand All @@ -272,7 +273,7 @@ object ChallengeRepository {
mediumPriorityRule ~ lowPriorityRule ~ defaultZoom ~ minZoom ~ maxZoom ~ defaultBasemap ~ defaultBasemapId ~
customBasemap ~ updateTasks ~ exportableProperties ~ osmIdProperty ~ taskBundleIdProperty ~ preferredTags ~ preferredReviewTags ~
limitTags ~ limitReviewTags ~ taskStyles ~ lastTaskRefresh ~ dataOriginDate ~ requiresLocal ~ location ~ bounding ~
deleted ~ virtualParents ~ isArchived ~ reviewSetting ~ taskWidgetLayout ~ systemArchivedAt =>
deleted ~ virtualParents ~ isArchived ~ reviewSetting ~ datasetUrl ~ taskWidgetLayout ~ systemArchivedAt =>
val hpr = highPriorityRule match {
case Some(c) if StringUtils.isEmpty(c) || StringUtils.equals(c, "{}") => None
case r => r
Expand Down Expand Up @@ -330,7 +331,8 @@ object ChallengeRepository {
isArchived,
reviewSetting,
taskWidgetLayout,
systemArchivedAt
datasetUrl,
systemArchivedAt,
),
status,
statusMessage,
Expand Down
19 changes: 14 additions & 5 deletions app/org/maproulette/models/dal/ChallengeDAL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class ChallengeDAL @Inject() (
get[Boolean]("deleted") ~
get[Boolean]("challenges.is_archived") ~
get[Int]("challenges.review_setting") ~
get[Option[String]]("challenges.dataset_url") ~
get[Option[JsValue]]("challenges.task_widget_layout") ~
get[Option[Int]]("challenges.completion_percentage") ~
get[Option[Int]]("challenges.tasks_remaining") map {
Expand All @@ -132,7 +133,7 @@ class ChallengeDAL @Inject() (
minZoom ~ maxZoom ~ defaultBasemap ~ defaultBasemapId ~ customBasemap ~ updateTasks ~
exportableProperties ~ osmIdProperty ~ taskBundleIdProperty ~ preferredTags ~ preferredReviewTags ~
limitTags ~ limitReviewTags ~ taskStyles ~ lastTaskRefresh ~ dataOriginDate ~ location ~ bounding ~
requiresLocal ~ deleted ~ isArchived ~ reviewSetting ~ taskWidgetLayout ~ completionPercentage ~ tasksRemaining =>
requiresLocal ~ deleted ~ isArchived ~ reviewSetting ~ datasetUrl ~ taskWidgetLayout ~ completionPercentage ~ tasksRemaining =>
val hpr = highPriorityRule match {
case Some(c) if StringUtils.isEmpty(c) || StringUtils.equals(c, "{}") => None
case r => r
Expand Down Expand Up @@ -189,7 +190,8 @@ class ChallengeDAL @Inject() (
taskBundleIdProperty,
isArchived,
reviewSetting,
taskWidgetLayout
taskWidgetLayout,
datasetUrl
),
status,
statusMessage,
Expand Down Expand Up @@ -259,6 +261,7 @@ class ChallengeDAL @Inject() (
get[Option[List[String]]]("presets") ~
get[Boolean]("challenges.is_archived") ~
get[Int]("challenges.review_setting") ~
get[Option[String]]("challenges.dataset_url") ~
get[Option[JsValue]]("challenges.task_widget_layout") ~
get[Option[DateTime]]("challenges.system_archived_at") ~
get[Option[Int]]("challenges.completion_percentage") ~
Expand All @@ -271,7 +274,7 @@ class ChallengeDAL @Inject() (
customBasemap ~ updateTasks ~ exportableProperties ~ osmIdProperty ~ taskBundleIdProperty ~ preferredTags ~
preferredReviewTags ~ limitTags ~ limitReviewTags ~ taskStyles ~ lastTaskRefresh ~
dataOriginDate ~ location ~ bounding ~ requiresLocal ~ deleted ~ virtualParents ~
presets ~ isArchived ~ reviewSetting ~ taskWidgetLayout ~ systemArchivedAt ~ completionPercentage ~ tasksRemaining =>
presets ~ isArchived ~ reviewSetting ~ datasetUrl ~ taskWidgetLayout ~ systemArchivedAt ~ completionPercentage ~ tasksRemaining =>
val hpr = highPriorityRule match {
case Some(c) if StringUtils.isEmpty(c) || StringUtils.equals(c, "{}") => None
case r => r
Expand Down Expand Up @@ -329,6 +332,7 @@ class ChallengeDAL @Inject() (
isArchived,
reviewSetting,
taskWidgetLayout,
datasetUrl,
systemArchivedAt,
presets
),
Expand Down Expand Up @@ -473,6 +477,7 @@ class ChallengeDAL @Inject() (

this.permission.hasObjectWriteAccess(challenge, user)
this.cacheManager.withOptionCaching { () =>
var a = "a"
val insertedChallenge =
this.withMRTransaction { implicit c =>
SQL"""INSERT INTO challenges (name, owner_id, parent_id, difficulty, description, info_link, blurb,
Expand All @@ -481,7 +486,7 @@ class ChallengeDAL @Inject() (
medium_priority_rule, low_priority_rule, default_zoom, min_zoom, max_zoom,
default_basemap, default_basemap_id, custom_basemap, updatetasks, exportable_properties,
osm_id_property, task_bundle_id_property, last_task_refresh, data_origin_date, preferred_tags, preferred_review_tags,
limit_tags, limit_review_tags, task_styles, requires_local, is_archived, review_setting, task_widget_layout)
limit_tags, limit_review_tags, task_styles, requires_local, is_archived, review_setting, dataset_url, task_widget_layout)
VALUES (${challenge.name}, ${challenge.general.owner}, ${challenge.general.parent}, ${challenge.general.difficulty},
${challenge.description}, ${challenge.infoLink}, ${challenge.general.blurb}, ${challenge.general.instruction},
${challenge.general.enabled}, ${challenge.general.featured},
Expand All @@ -495,7 +500,7 @@ class ChallengeDAL @Inject() (
${challenge.dataOriginDate.getOrElse(DateTime.now()).toString}::timestamptz,
${challenge.extra.preferredTags}, ${challenge.extra.preferredReviewTags}, ${challenge.extra.limitTags},
${challenge.extra.limitReviewTags}, ${challenge.extra.taskStyles}, ${challenge.general.requiresLocal}, ${challenge.extra.isArchived},
${challenge.extra.reviewSetting},
${challenge.extra.reviewSetting}, ${challenge.extra.datasetUrl},
${asJson(challenge.extra.taskWidgetLayout.getOrElse(Json.parse("{}")))}
) ON CONFLICT(parent_id, LOWER(name)) DO NOTHING RETURNING #${this.retrieveColumns}"""
.as(this.parser.*)
Expand Down Expand Up @@ -683,6 +688,10 @@ class ChallengeDAL @Inject() (
.asOpt[Int]
.getOrElse(cachedItem.extra.reviewSetting)

val datasetUrl = (updates \ "datasetUrl")
.asOpt[String]
.getOrElse(cachedItem.extra.datasetUrl)

val taskWidgetLayout = (updates \ "taskWidgetLayout")
.asOpt[JsValue]
.getOrElse(cachedItem.extra.taskWidgetLayout.getOrElse(Json.parse("{}")))
Expand Down
5 changes: 5 additions & 0 deletions conf/evolutions/default/97.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# --- !Ups
ALTER TABLE challenges ADD COLUMN dataset_url VARCHAR DEFAULT NULL;;

# --- !Downs
ALTER TABLE IF EXISTS challenges DROP COLUMN dataset_url;;

0 comments on commit fa34a32

Please sign in to comment.