-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Make pipeline version per Organism" (#3702)
* Revert "Make pipeline version per Organism (#3534)" This reverts commit 7166188. * Update schema documentation based on migration changes * dummy for ci --------- Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Cornelius Roemer <[email protected]>
- Loading branch information
1 parent
946f44e
commit 0f24409
Showing
18 changed files
with
125 additions
and
435 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
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
42 changes: 0 additions & 42 deletions
42
.../src/main/kotlin/org/loculus/backend/service/submission/CurrentProcessingPipelineTable.kt
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 |
---|---|---|
@@ -1,53 +1,11 @@ | ||
package org.loculus.backend.service.submission | ||
|
||
import kotlinx.datetime.LocalDateTime | ||
import org.jetbrains.exposed.sql.Table | ||
import org.jetbrains.exposed.sql.andWhere | ||
import org.jetbrains.exposed.sql.batchInsert | ||
import org.jetbrains.exposed.sql.kotlin.datetime.datetime | ||
import org.jetbrains.exposed.sql.selectAll | ||
import org.jetbrains.exposed.sql.update | ||
|
||
const val CURRENT_PROCESSING_PIPELINE_TABLE_NAME = "current_processing_pipeline" | ||
|
||
object CurrentProcessingPipelineTable : Table(CURRENT_PROCESSING_PIPELINE_TABLE_NAME) { | ||
val organismColumn = varchar("organism", 255) | ||
val versionColumn = long("version") | ||
val startedUsingAtColumn = datetime("started_using_at") | ||
|
||
/** | ||
* Every organism needs to have a current pipeline version in the CurrentProcessingPipelineTable. | ||
* This function sets V1 for all given organisms, if no version is defined yet. | ||
*/ | ||
fun setV1ForOrganismsIfNotExist(organisms: Collection<String>, now: LocalDateTime) = | ||
CurrentProcessingPipelineTable.batchInsert(organisms, ignore = true) { organism -> | ||
this[organismColumn] = organism | ||
this[versionColumn] = 1 | ||
this[startedUsingAtColumn] = now | ||
} | ||
|
||
/** | ||
* Given a version that was found that is potentially newer than the current once, check if the currently stored | ||
* 'current' pipeline version for this organism is less than the one that was found? | ||
* If so, the pipeline needs to 'update' i.e. reprocess older entries. | ||
*/ | ||
fun pipelineNeedsUpdate(maybeNewerVersion: Long, organism: String) = CurrentProcessingPipelineTable | ||
.selectAll() | ||
.where { versionColumn less maybeNewerVersion } | ||
.andWhere { organismColumn eq organism } | ||
.empty() | ||
.not() | ||
|
||
/** | ||
* Set the pipeline version for the given organism to newVersion. | ||
*/ | ||
fun updatePipelineVersion(organism: String, newVersion: Long, startedUsingAt: LocalDateTime) = | ||
CurrentProcessingPipelineTable.update( | ||
where = { | ||
organismColumn eq organism | ||
}, | ||
) { | ||
it[versionColumn] = newVersion | ||
it[startedUsingAtColumn] = startedUsingAt | ||
} | ||
} |
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
Oops, something went wrong.