-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #547 from NDLANO/learningpath-made-available-date
learningpath-api: Adds `madeAvailable` field to learningpaths
- Loading branch information
Showing
7 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...c/main/scala/no/ndla/learningpathapi/db/migration/V39__MadeAvailableForThePublished.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Part of NDLA learningpath-api | ||
* Copyright (C) 2024 NDLA | ||
* | ||
* See LICENSE | ||
* | ||
*/ | ||
|
||
package no.ndla.learningpathapi.db.migration | ||
|
||
import no.ndla.common.CirceUtil | ||
import no.ndla.common.model.domain.learningpath.LearningPath | ||
import no.ndla.common.model.domain.learningpath.LearningPathStatus.{PUBLISHED, UNLISTED} | ||
import no.ndla.database.DocumentMigration | ||
|
||
class V39__MadeAvailableForThePublished extends DocumentMigration { | ||
override val columnName: String = "document" | ||
override val tableName: String = "learningpaths" | ||
|
||
protected def convertColumn(document: String): String = { | ||
val oldLp = CirceUtil.unsafeParseAs[LearningPath](document) | ||
val madeAvailable = oldLp.status match { | ||
case UNLISTED | PUBLISHED => Some(oldLp.lastUpdated) | ||
case _ => None | ||
} | ||
|
||
val newLearningPath = oldLp.copy(madeAvailable = madeAvailable) | ||
CirceUtil.toJsonString(newLearningPath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters