Skip to content

Commit

Permalink
EP Merge: Fixed issue with created_at being incorrectly set. (#2695)
Browse files Browse the repository at this point in the history
Fixed issue with created_at being incorrectly set.
  • Loading branch information
dfitchett authored Mar 2, 2024
1 parent 113f8cc commit f6d4550
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions domain-ee/ee-ep-merge-app/src/python_src/model/merge_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from sqlalchemy import Column, DateTime, Integer, String
from sqlalchemy.dialects.postgresql import ARRAY, JSONB, UUID
from sqlalchemy.ext.mutable import MutableDict
from sqlalchemy.sql import func


class MergeJob(Base):
Expand All @@ -16,5 +15,5 @@ class MergeJob(Base):
state = Column(String, index=True)
error_state = Column(String)
messages = Column(ARRAY(MutableDict.as_mutable(JSONB)))
created_at = Column(DateTime, default=func.now())
updated_at = Column(DateTime, default=func.now(), onupdate=func.now())
created_at = Column(DateTime)
updated_at = Column(DateTime)
13 changes: 8 additions & 5 deletions domain-ee/ee-ep-merge-app/src/python_src/schema/merge_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from uuid import UUID

import model.merge_job
from pydantic import BaseModel, ConfigDict, conint
from typing_extensions import ClassVar
from pydantic import BaseModel, ConfigDict, conint, Field
from util.custom_enum import StrEnum


Expand Down Expand Up @@ -38,16 +37,20 @@ def __str__(self):


class MergeJob(BaseModel):
_init_time: ClassVar[datetime] = datetime.now()

job_id: UUID
pending_claim_id: conint(strict=True)
ep400_claim_id: conint(strict=True)
state: JobState = JobState.PENDING
error_state: JobState | None = None
messages: list[Any] | None = None
created_at: datetime = _init_time
updated_at: datetime = _init_time
created_at: datetime = Field(default_factory=datetime.now)
updated_at: datetime = None

def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
if not self.updated_at:
self.updated_at = self.created_at

model_config = ConfigDict(from_attributes=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def on_completed(self, event):
f"job_id={self.job.job_id} "
f"pending_claim_id={self.job.pending_claim_id} "
f"ep400_claim_id={self.job.ep400_claim_id} "
f"state={self.job.state}"
f"state={self.job.state} "
f"job_duration_seconds={job_duration}"
)

Expand Down

0 comments on commit f6d4550

Please sign in to comment.