Skip to content

Commit

Permalink
Use status instead of column
Browse files Browse the repository at this point in the history
  • Loading branch information
frcroth committed Nov 13, 2023
1 parent bc220c4 commit 5349251
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 56 deletions.
58 changes: 28 additions & 30 deletions app/models/dataset/Dataset.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,30 @@ import utils.ObjectId

import scala.concurrent.ExecutionContext

case class Dataset(
_id: ObjectId,
_dataStore: String,
_organization: ObjectId,
_publication: Option[ObjectId],
_uploader: Option[ObjectId],
_folder: ObjectId,
inboxSourceHash: Option[Int],
defaultViewConfiguration: Option[DatasetViewConfiguration] = None,
adminViewConfiguration: Option[DatasetViewConfiguration] = None,
description: Option[String] = None,
displayName: Option[String] = None,
isPublic: Boolean,
isUsable: Boolean,
name: String,
scale: Option[Vec3Double],
sharingToken: Option[String],
status: String,
logoUrl: Option[String],
sortingKey: Instant = Instant.now,
details: Option[JsObject] = None,
tags: Set[String] = Set.empty,
created: Instant = Instant.now,
isDeleted: Boolean = false,
isRemovedOnDisk: Boolean = false
) extends FoxImplicits {
case class Dataset(_id: ObjectId,
_dataStore: String,
_organization: ObjectId,
_publication: Option[ObjectId],
_uploader: Option[ObjectId],
_folder: ObjectId,
inboxSourceHash: Option[Int],
defaultViewConfiguration: Option[DatasetViewConfiguration] = None,
adminViewConfiguration: Option[DatasetViewConfiguration] = None,
description: Option[String] = None,
displayName: Option[String] = None,
isPublic: Boolean,
isUsable: Boolean,
name: String,
scale: Option[Vec3Double],
sharingToken: Option[String],
status: String,
logoUrl: Option[String],
sortingKey: Instant = Instant.now,
details: Option[JsObject] = None,
tags: Set[String] = Set.empty,
created: Instant = Instant.now,
isDeleted: Boolean = false)
extends FoxImplicits {

def urlEncodedName: String =
UriEncoding.encodePathSegment(name, "UTF-8")
Expand Down Expand Up @@ -94,6 +92,7 @@ class DatasetDAO @Inject()(sqlClient: SqlClient, datasetLayerDAO: DatasetLayerDA
protected def isDeletedColumn(x: Datasets): Rep[Boolean] = x.isdeleted

val unreportedStatus: String = "No longer available on datastore."
val deletedByUserStatus: String = "Deleted by user."

private def parseScaleOpt(literalOpt: Option[String]): Fox[Option[Vec3Double]] = literalOpt match {
case Some(literal) =>
Expand Down Expand Up @@ -135,8 +134,7 @@ class DatasetDAO @Inject()(sqlClient: SqlClient, datasetLayerDAO: DatasetLayerDA
details,
parseArrayLiteral(r.tags).toSet,
Instant.fromSql(r.created),
r.isdeleted,
r.isremovedondisk
r.isdeleted
)
}

Expand Down Expand Up @@ -317,7 +315,7 @@ class DatasetDAO @Inject()(sqlClient: SqlClient, datasetLayerDAO: DatasetLayerDA
.getOrElse(q"${true}")
searchPredicate = buildSearchPredicate(searchQuery)
isUnreportedPredicate = buildIsUnreportedPredicate(isUnreported)
excludeRemovedOnDiskPredicate = if (excludeRemovedOnDisk) q"isRemovedOnDisk != true" else q"${true}"
excludeRemovedOnDiskPredicate = if (excludeRemovedOnDisk) q"status != $deletedByUserStatus" else q"${true}"
} yield q"""
($folderPredicate)
AND ($uploaderPredicate)
Expand Down Expand Up @@ -573,7 +571,7 @@ class DatasetDAO @Inject()(sqlClient: SqlClient, datasetLayerDAO: DatasetLayerDA
val deleteAllowedTeamsQuery = q"delete from webknossos.dataSet_allowedTeams where _dataset = $datasetId".asUpdate
val deleteDatasetQuery =
if (onlyMarkAsDeleted)
q"update webknossos.datasets set isRemovedOnDisk = true where _id = $datasetId".asUpdate
q"update webknossos.datasets set status = $deletedByUserStatus where _id = $datasetId".asUpdate
else
q"delete from webknossos.datasets where _id = $datasetId".asUpdate

Expand Down
13 changes: 0 additions & 13 deletions conf/evolutions/110-mark-datasets-as-deleted-on-disk.sql

This file was deleted.

11 changes: 0 additions & 11 deletions conf/evolutions/reversions/110-mark-dataset-as-deleted-on-disk.sql

This file was deleted.

3 changes: 1 addition & 2 deletions tools/postgres/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CREATE TABLE webknossos.releaseInformation (
schemaVersion BIGINT NOT NULL
);

INSERT INTO webknossos.releaseInformation(schemaVersion) values(110);
INSERT INTO webknossos.releaseInformation(schemaVersion) values(109);
COMMIT TRANSACTION;


Expand Down Expand Up @@ -123,7 +123,6 @@ CREATE TABLE webknossos.dataSets(
details JSONB,
tags VARCHAR(256)[] NOT NULL DEFAULT '{}',
created TIMESTAMPTZ NOT NULL DEFAULT NOW(),
isRemovedOnDisk BOOLEAN NOT NULL DEFAULT false,
isDeleted BOOLEAN NOT NULL DEFAULT false,
UNIQUE (name, _organization),
CONSTRAINT defaultViewConfigurationIsJsonObject CHECK(jsonb_typeof(defaultViewConfiguration) = 'object'),
Expand Down

0 comments on commit 5349251

Please sign in to comment.