Skip to content

Commit

Permalink
Merge branch 'release-0.2.0' into feat/hamed-fse-form-wording-update-…
Browse files Browse the repository at this point in the history
…1468
  • Loading branch information
hamed-valiollahi authored Dec 17, 2024
2 parents 33d3ddf + bb9e0e6 commit f870eb3
Show file tree
Hide file tree
Showing 48 changed files with 1,707 additions and 439 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""update notification message model
Revision ID: f93546eaec61
Revises: 5d729face5ab
Create Date: 2024-12-17 11:23:19.563138
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "f93546eaec61"
down_revision = "5d729face5ab"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("notification_message", sa.Column("type", sa.Text(), nullable=False))
op.add_column(
"notification_message",
sa.Column("related_transaction_id", sa.Text(), nullable=False),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("notification_message", "related_transaction_id")
op.drop_column("notification_message", "type")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Add legacy id to compliance reports
Revision ID: 5b374dd97469
Revises: f93546eaec61
Create Date: 2024-17-13 12:25:32.076684
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "5b374dd97469"
down_revision = "f93546eaec61"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"compliance_report",
sa.Column(
"legacy_id",
sa.Integer(),
nullable=True,
comment="ID from TFRS if this is a transferred application, NULL otherwise",
),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("compliance_report", "legacy_id")
# ### end Alembic commands ###
5 changes: 5 additions & 0 deletions backend/lcfs/db/models/compliance/ComplianceReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class ComplianceReport(BaseModel, Auditable):
default=lambda: str(uuid.uuid4()),
comment="UUID that groups all versions of a compliance report",
)
legacy_id = Column(
Integer,
nullable=True,
comment="ID from TFRS if this is a transferred application, NULL otherwise",
)
version = Column(
Integer,
nullable=False,
Expand Down
8 changes: 3 additions & 5 deletions backend/lcfs/db/models/notification/NotificationMessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class NotificationMessage(BaseModel, Auditable):
is_warning = Column(Boolean, default=False)
is_error = Column(Boolean, default=False)
is_archived = Column(Boolean, default=False)
type = Column(Text, nullable=False)
message = Column(Text, nullable=False)

related_organization_id = Column(
Expand All @@ -32,12 +33,9 @@ class NotificationMessage(BaseModel, Auditable):
notification_type_id = Column(
Integer, ForeignKey("notification_type.notification_type_id")
)
related_transaction_id = Column(Text, nullable=False)

# Models not created yet
# related_transaction_id = Column(Integer,ForeignKey(''))
# related_document_id = Column(Integer, ForeignKey('document.id'))
# related_report_id = Column(Integer, ForeignKey('compliance_report.id'))

# Relationships
related_organization = relationship(
"Organization", back_populates="notification_messages"
)
Expand Down
5 changes: 3 additions & 2 deletions backend/lcfs/services/rabbitmq/base_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import aio_pika
from aio_pika.abc import AbstractChannel, AbstractQueue
from fastapi import FastAPI

from lcfs.settings import settings

Expand All @@ -12,11 +13,12 @@


class BaseConsumer:
def __init__(self, queue_name=None):
def __init__(self, app: FastAPI, queue_name: str):
self.connection = None
self.channel = None
self.queue = None
self.queue_name = queue_name
self.app = app

async def connect(self):
"""Connect to RabbitMQ and set up the consumer."""
Expand All @@ -42,7 +44,6 @@ async def start_consuming(self):
async with message.process():
logger.debug(f"Received message: {message.body.decode()}")
await self.process_message(message.body)
logger.debug("Message Processed")

async def process_message(self, body: bytes):
"""Process the incoming message. Override this method in subclasses."""
Expand Down
12 changes: 6 additions & 6 deletions backend/lcfs/services/rabbitmq/consumers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import asyncio

from lcfs.services.rabbitmq.transaction_consumer import (
setup_transaction_consumer,
close_transaction_consumer,
from lcfs.services.rabbitmq.report_consumer import (
setup_report_consumer,
close_report_consumer,
)


async def start_consumers():
await setup_transaction_consumer()
async def start_consumers(app):
await setup_report_consumer(app)


async def stop_consumers():
await close_transaction_consumer()
await close_report_consumer()
Loading

0 comments on commit f870eb3

Please sign in to comment.