Skip to content

Commit

Permalink
Adjust context used
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobessa committed Dec 20, 2024
1 parent 1c086a2 commit 6d14d5b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions vintasend_sqlalchemy/alembic_initial_migration_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def create_notification_table(user_id_type: type):
sa.Column('preheader_template', sa.String(255), nullable=True, default=""),
sa.Column('context_name', sa.String(255), nullable=True, default=""),
sa.Column('context_kwargs', sa.JSON, default=dict),
sa.Column('context_used', sa.JSON, nullable=True),
sa.Column('metadata_json', sa.JSON, nullable=True),
sa.Column('send_after', sa.DateTime(), nullable=True),
sa.Column('user_id', user_id_type(), nullable=False),
Expand Down
1 change: 1 addition & 0 deletions vintasend_sqlalchemy/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class NotificationMixin(Base):
preheader_template: Mapped[str] = mapped_column("preheader_template", String(255), nullable=True, default="")
context_name: Mapped[str] = mapped_column("context_name", String(255), nullable=True, default="")
context_kwargs: Mapped[dict] = mapped_column("context_kwargs", JSON, default=dict)
context_used: Mapped[dict | None] = mapped_column("context_used", JSON, nullable=True)
metadata_json: Mapped[dict | None] = mapped_column("metadata_json", JSON, nullable=True)

send_after = mapped_column("send_after", DateTime, nullable=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def store_context_used(self, notification_id: int | str | uuid.UUID, context: di
)
.one()
)
notification.context_kwargs = context
notification.context_used = context
session.commit()
session.flush()

Expand Down Expand Up @@ -770,5 +770,5 @@ async def store_context_used(
)
)
).one()[0]
notification.context_kwargs = context
notification.context_used = context
await session.commit()

0 comments on commit 6d14d5b

Please sign in to comment.