Skip to content

Commit

Permalink
Merge branch 'main' into 108-extract-document-text
Browse files Browse the repository at this point in the history
  • Loading branch information
mawandm authored Jun 17, 2024
2 parents bf8d1f8 + 8417fb8 commit fc36f2e
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,15 @@
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index("idx_model_name", table_name="model")
op.drop_table("model")
op.drop_table("model_rule")
op.drop_constraint("fk_rule_model", "prediction", type_="foreignkey")
op.drop_table("model")
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###

op.create_table(
"model_rule",
sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False),
sa.Column("name", sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column("model", sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column(
"description", sa.VARCHAR(length=255), autoincrement=False, nullable=True
),
sa.Column(
"created_by", sa.VARCHAR(length=255), autoincrement=False, nullable=True
),
sa.Column(
"create_date", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
sa.Column(
"value",
postgresql.JSONB(astext_type=sa.Text()),
autoincrement=False,
nullable=False,
),
sa.Column("enabled", sa.BOOLEAN(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["model"], ["model.id"], name="fk_model_rule_model", ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id", name="model_rule_pkey"),
sa.UniqueConstraint("name", name="model_rule_name_key"),
)
op.create_table(
"model",
sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False),
Expand Down Expand Up @@ -87,6 +60,34 @@ def downgrade() -> None:
sa.PrimaryKeyConstraint("id", name="model_pkey"),
sa.UniqueConstraint("module", "name", name="uq_model_module_name"),
)

op.create_table(
"model_rule",
sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False),
sa.Column("name", sa.VARCHAR(length=255), autoincrement=False, nullable=True),
sa.Column("model", sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column(
"description", sa.VARCHAR(length=255), autoincrement=False, nullable=True
),
sa.Column(
"created_by", sa.VARCHAR(length=255), autoincrement=False, nullable=True
),
sa.Column(
"create_date", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
sa.Column(
"value",
postgresql.JSONB(astext_type=sa.Text()),
autoincrement=False,
nullable=False,
),
sa.Column("enabled", sa.BOOLEAN(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["model"], ["model.id"], name="fk_model_rule_model", ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id", name="model_rule_pkey"),
sa.UniqueConstraint("name", name="model_rule_name_key"),
)
op.create_index("idx_model_name", "model", ["module", "name"], unique=False)
op.create_foreign_key(
"fk_rule_model", "prediction", "model", ["model"], ["id"], ondelete="CASCADE"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""add tasks to role_action_resource_type
Revision ID: 50bebf15de30
Revises: 3d6d802ca102
Create Date: 2024-06-13 23:41:54.517558
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "50bebf15de30"
down_revision: Union[str, None] = "3d6d802ca102"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.execute("ALTER TYPE role_action_resource_type ADD VALUE 'APPS';")
op.execute("ALTER TYPE role_action_resource_type ADD VALUE 'TASKS';")
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
"""
We keep the APPS and TASKS types as might be used by the application
"""
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""add parent_id to task unique constraint
Revision ID: cbad6afbe13d
Revises: 50bebf15de30
Create Date: 2024-06-13 23:59:45.211996
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "cbad6afbe13d"
down_revision: Union[str, None] = "50bebf15de30"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint("uq_task_type_schedule", "task", type_="unique")
op.create_unique_constraint(
"uq_task_parent_id_type_schedule", "task", ["parent_id", "type", "schedule"]
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint("uq_task_parent_id_type_schedule", "task", type_="unique")
op.create_unique_constraint("uq_task_type_schedule", "task", ["type", "schedule"])
# ### end Alembic commands ###
4 changes: 3 additions & 1 deletion nesis/api/core/models/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ class Task(Base):
update_date = Column(DateTime, default=dt.datetime.utcnow, nullable=False)

__table_args__ = (
UniqueConstraint("type", "schedule", name="uq_task_type_schedule"),
UniqueConstraint(
"parent_id", "type", "schedule", name="uq_task_parent_id_type_schedule"
),
Index("idx_task_type", "type"),
Index("idx_task_parent", "parent_id"),
)
Expand Down
2 changes: 1 addition & 1 deletion nesis/api/core/services/task_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def create(self, **kwargs):
error_str = str(exc).lower()

if ("unique constraint" in error_str) and (
"uq_task_type_schedule" in error_str
"uq_task_parent_id_type_schedule" in error_str
):
# valid failure
raise ConflictException("Task already scheduled on this type")
Expand Down
22 changes: 12 additions & 10 deletions nesis/frontend/client/src/SessionContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@ export function useSignOut(client, config) {

async function logoutMicrosoft(config) {
try {
const msalInstance = new PublicClientApplication({
auth: {
clientId: config?.auth?.OAUTH_AZURE_CLIENT_ID,
authority: config?.auth?.OAUTH_AZURE_AUTHORITY,
redirectUri: config?.auth?.OAUTH_AZURE_REDIRECTURI,
postLogoutRedirectUri: config?.auth?.OAUTH_AZURE_REDIRECTURI,
},
});
await msalInstance.initialize();
await msalInstance.logoutRedirect();
if (config?.auth?.NESIS_OAUTH_AZURE_ENABLED) {
const msalInstance = new PublicClientApplication({
auth: {
clientId: config?.auth?.OAUTH_AZURE_CLIENT_ID,
authority: config?.auth?.OAUTH_AZURE_AUTHORITY,
redirectUri: config?.auth?.OAUTH_AZURE_REDIRECTURI,
postLogoutRedirectUri: config?.auth?.OAUTH_AZURE_REDIRECTURI,
},
});
await msalInstance.initialize();
await msalInstance.logoutRedirect();
}
} catch (e) {
/* ignored */
}
Expand Down

0 comments on commit fc36f2e

Please sign in to comment.