From ea1ab2cefb6a94e89380396351f8d2a5ca0c9995 Mon Sep 17 00:00:00 2001 From: Sebastian Aranda Date: Tue, 17 Dec 2024 09:17:24 -0300 Subject: [PATCH] Temporal commit. --- .../1b085cf9c085_add_columns_json_to_jira_fields_table.py | 8 ++++---- src/narrativelog/message.py | 6 ++++++ src/narrativelog/routers/add_message.py | 8 ++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/alembic/versions/1b085cf9c085_add_columns_json_to_jira_fields_table.py b/alembic/versions/1b085cf9c085_add_columns_json_to_jira_fields_table.py index 807c27b..5ba5841 100644 --- a/alembic/versions/1b085cf9c085_add_columns_json_to_jira_fields_table.py +++ b/alembic/versions/1b085cf9c085_add_columns_json_to_jira_fields_table.py @@ -24,11 +24,11 @@ def upgrade(log: logging.Logger, table_names: set[str]) -> None: if JIRA_FIELDS_TABLE_NAME not in table_names: log.info(f"No {JIRA_FIELDS_TABLE_NAME} table; nothing to do") return - log.info("Add 'columns_json'") + log.info("Add 'components_json'") op.add_column( JIRA_FIELDS_TABLE_NAME, - sa.Column("columns_json", sa.JSON(), nullable=True), + sa.Column("components_json", sa.JSON(), nullable=True), ) @@ -37,5 +37,5 @@ def downgrade(log: logging.Logger, table_names: set[str]) -> None: log.info(f"No {JIRA_FIELDS_TABLE_NAME} table; nothing to do") return - log.info("Drop 'columns_json'") - op.drop_column(JIRA_FIELDS_TABLE_NAME, "columns_json") + log.info("Drop 'components_json'") + op.drop_column(JIRA_FIELDS_TABLE_NAME, "components_json") diff --git a/src/narrativelog/message.py b/src/narrativelog/message.py index d009a4e..241628b 100644 --- a/src/narrativelog/message.py +++ b/src/narrativelog/message.py @@ -78,6 +78,11 @@ class Message(BaseModel): time_lost_type: None | str = Field( title="Type of time lost.", ) + # Added 2024-12-16 + components_json: None | dict = Field( + default_factory=dict, + title="JSON representation of systems and subsystems on the OBS jira project.", + ) class Config: orm_mode = True @@ -88,6 +93,7 @@ class Config: "components", "primary_software_components", "primary_hardware_components", + "components_json", ) MESSAGE_FIELDS = tuple( set(Message.schema()["properties"].keys()) - set(JIRA_FIELDS) diff --git a/src/narrativelog/routers/add_message.py b/src/narrativelog/routers/add_message.py index 74c41c7..66a9f21 100644 --- a/src/narrativelog/routers/add_message.py +++ b/src/narrativelog/routers/add_message.py @@ -73,6 +73,12 @@ async def add_message( description="Primary hardware components to which the message applies. " "Each entry should be a valid component name entry on the OBS jira project.", ), + components_json: None + | dict = fastapi.Body( + default={}, + description="JSON representation of systems and subsystems" + " on the OBS jira project.", + ), urls: list[str] = fastapi.Body( default=[], description="URLs of associated JIRA tickets, screen shots, etc.: " @@ -169,6 +175,7 @@ async def add_message( components, primary_software_components, primary_hardware_components, + components_json, ) ): result_jira_fields = await connection.execute( @@ -177,6 +184,7 @@ async def add_message( components=components, primary_software_components=primary_software_components, primary_hardware_components=primary_hardware_components, + components_json=components_json, message_id=row_message.id, ) .returning(sa.literal_column("*"))