added "active" column for hierarchie suggestions
This commit is contained in:
@@ -92,6 +92,27 @@ def create_db_and_tables():
|
||||
"VARCHAR NOT NULL DEFAULT 'new'"
|
||||
)
|
||||
)
|
||||
if "active" not in hierarchy_edit_columns:
|
||||
with engine.begin() as connection:
|
||||
connection.execute(
|
||||
text(
|
||||
"ALTER TABLE hierarchy_edits ADD COLUMN active "
|
||||
"BOOLEAN NOT NULL DEFAULT FALSE"
|
||||
)
|
||||
)
|
||||
connection.execute(
|
||||
text(
|
||||
"UPDATE hierarchy_edits AS current_edit SET active = TRUE "
|
||||
"WHERE current_edit.status = 'accepted' "
|
||||
"AND current_edit.created_at = ("
|
||||
"SELECT MAX(previous_edit.created_at) "
|
||||
"FROM hierarchy_edits AS previous_edit "
|
||||
"WHERE previous_edit.organization_openalex_id = "
|
||||
"current_edit.organization_openalex_id "
|
||||
"AND previous_edit.status = 'accepted'"
|
||||
")"
|
||||
)
|
||||
)
|
||||
_migrate_secret_table()
|
||||
columns = {column["name"] for column in inspect(engine).get_columns("account")}
|
||||
if "activated" not in columns:
|
||||
|
||||
@@ -37,6 +37,7 @@ class HierarchySuggestion(BaseModel):
|
||||
id: uuid.UUID
|
||||
created_at: datetime
|
||||
status: HierarchySuggestionStatus
|
||||
active: bool
|
||||
hierarchy: list[HierarchyNode]
|
||||
|
||||
class OrgminerKeyword(BaseModel):
|
||||
@@ -214,6 +215,7 @@ class EditHierarchySuggestion(SQLModel, table=True):
|
||||
slot: int = Field(nullable=False)
|
||||
file_path: str = Field(nullable=False)
|
||||
status: str = Field(default="new", nullable=False, index=True)
|
||||
active: bool = Field(default=False, nullable=False, index=True)
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint("account_id", "day", "slot", name="uq_suggestion_account_day_slot"),
|
||||
|
||||
Reference in New Issue
Block a user