Skip to content

Commit

Permalink
Standardize the "is_public" column across the dataset and workflow ta…
Browse files Browse the repository at this point in the history
…bles. (#3168)

### Purpose:
Although the column indicating publication already exists in both the
dataset and workflow tables, they have different names and types.

### Change:
Modified the dataset and workflow tables to unify the format of
is_public across different tables. **To complete the database update,
please execute `18.sql` located in the update folder.**
  • Loading branch information
GspikeHalo authored Dec 18, 2024
1 parent 64dd0c1 commit 7ae89dc
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ object WorkflowSearchQueryBuilder extends SearchQueryBuilder {

var condition: Condition = DSL.trueCondition()
if (uid == null) {
condition = WORKFLOW.IS_PUBLISHED.eq(1.toByte)
condition = WORKFLOW.IS_PUBLIC.eq(1.toByte)
} else {
val privateAccessCondition =
WORKFLOW_USER_ACCESS.UID.eq(uid).or(PROJECT_USER_ACCESS.UID.eq(uid))
if (includePublic) {
condition = privateAccessCondition.or(WORKFLOW.IS_PUBLISHED.eq(1.toByte))
condition = privateAccessCondition.or(WORKFLOW.IS_PUBLIC.eq(1.toByte))
} else {
condition = privateAccessCondition
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class HubWorkflowResource {
def getPublishedWorkflowCount: Integer = {
context.selectCount
.from(WORKFLOW)
.where(WORKFLOW.IS_PUBLISHED.eq(1.toByte))
.where(WORKFLOW.IS_PUBLIC.eq(1.toByte))
.fetchOne(0, classOf[Integer])
}

Expand Down Expand Up @@ -174,7 +174,7 @@ class HubWorkflowResource {
val workflow = workflowDao.ctx
.selectFrom(WORKFLOW)
.where(WORKFLOW.WID.eq(wid))
.and(WORKFLOW.IS_PUBLISHED.isTrue)
.and(WORKFLOW.IS_PUBLIC.isTrue)
.fetchOne()
WorkflowWithPrivilege(
workflow.getName,
Expand All @@ -183,7 +183,7 @@ class HubWorkflowResource {
workflow.getContent,
workflow.getCreationTime,
workflow.getLastModifiedTime,
workflow.getIsPublished,
workflow.getIsPublic,
readonly = true
)
}
Expand Down Expand Up @@ -328,7 +328,7 @@ class HubWorkflowResource {
.from(WORKFLOW_USER_LIKES)
.join(WORKFLOW)
.on(WORKFLOW_USER_LIKES.WID.eq(WORKFLOW.WID))
.where(WORKFLOW.IS_PUBLISHED.eq(1.toByte))
.where(WORKFLOW.IS_PUBLIC.eq(1.toByte))
.groupBy(WORKFLOW_USER_LIKES.WID)
.orderBy(DSL.count(WORKFLOW_USER_LIKES.WID).desc())
.limit(8)
Expand All @@ -350,7 +350,7 @@ class HubWorkflowResource {
.from(WORKFLOW_USER_CLONES)
.join(WORKFLOW)
.on(WORKFLOW_USER_CLONES.WID.eq(WORKFLOW.WID))
.where(WORKFLOW.IS_PUBLISHED.eq(1.toByte))
.where(WORKFLOW.IS_PUBLIC.eq(1.toByte))
.groupBy(WORKFLOW_USER_CLONES.WID)
.orderBy(DSL.count(WORKFLOW_USER_CLONES.WID).desc())
.limit(8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object WorkflowAccessResource {

def isPublic(wid: UInteger): Boolean = {
context
.select(WORKFLOW.IS_PUBLISHED)
.select(WORKFLOW.IS_PUBLIC)
.from(WORKFLOW)
.where(WORKFLOW.WID.eq(wid))
.fetchOneInto(classOf[Boolean])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class WorkflowResource extends LazyLogging {
workflow.getContent,
workflow.getCreationTime,
workflow.getLastModifiedTime,
workflow.getIsPublished,
workflow.getIsPublic,
!WorkflowAccessResource.hasWriteAccess(wid, user.getUid)
)
} else {
Expand Down Expand Up @@ -568,23 +568,23 @@ class WorkflowResource extends LazyLogging {
@Path("/public/{wid}")
def makePublic(@PathParam("wid") wid: UInteger, @Auth user: SessionUser): Unit = {
val workflow: Workflow = workflowDao.fetchOneByWid(wid)
workflow.setIsPublished(1.toByte)
workflow.setIsPublic(1.toByte)
workflowDao.update(workflow)
}

@PUT
@Path("/private/{wid}")
def makePrivate(@PathParam("wid") wid: UInteger): Unit = {
val workflow: Workflow = workflowDao.fetchOneByWid(wid)
workflow.setIsPublished(0.toByte)
workflow.setIsPublic(0.toByte)
workflowDao.update(workflow)
}

@GET
@Path("/type/{wid}")
def getWorkflowType(@PathParam("wid") wid: UInteger): String = {
val workflow: Workflow = workflowDao.fetchOneByWid(wid)
if (workflow.getIsPublished == 1.toByte) {
if (workflow.getIsPublic == 1.toByte) {
"Public"
} else {
"Private"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion core/scripts/sql/texera_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,10 @@ CREATE TABLE IF NOT EXISTS workflow_view_count
`view_count` INT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`wid`),
FOREIGN KEY (`wid`) REFERENCES `workflow` (`wid`) ON DELETE CASCADE
) ENGINE = INNODB;
) ENGINE = INNODB;

ALTER TABLE dataset
MODIFY COLUMN is_public BOOLEAN NOT NULL DEFAULT true;

ALTER TABLE workflow
CHANGE COLUMN is_published is_public BOOLEAN NOT NULL DEFAULT false;
7 changes: 7 additions & 0 deletions core/scripts/sql/update/18.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
USE texera_db;

ALTER TABLE dataset
MODIFY COLUMN is_public BOOLEAN NOT NULL DEFAULT true;

ALTER TABLE workflow
CHANGE COLUMN is_published is_public BOOLEAN NOT NULL DEFAULT false;

0 comments on commit 7ae89dc

Please sign in to comment.