Skip to content

Commit

Permalink
Merge branch 'upgrades' of github.com:open-contracting/credere-backen…
Browse files Browse the repository at this point in the history
…d into upgrades
  • Loading branch information
yolile committed Dec 15, 2023
2 parents 8b105ff + 04f931d commit a4503b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,5 +758,7 @@ class Statistic(SQLModel, table=True):
id: int | None = Field(default=None, primary_key=True)
type: StatisticType = Field(sa_column=Column(Enum(StatisticType, name="statistic_type")))
data: dict[str, Any] = Field(default={}, sa_column=Column(JSON))
created_at: datetime | None = Field(sa_column=Column(DateTime(timezone=True), nullable=False, onupdate=func.now()))
created_at: datetime | None = Field(
sa_column=Column(DateTime(timezone=True), nullable=False, default=datetime.utcnow(), server_default=func.now())
)
lender_id: int | None = Field(foreign_key="lender.id", nullable=True)
3 changes: 0 additions & 3 deletions app/utils/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def update_statistics(db_provider: Callable[[], Generator[Session, None, None]]
statistic_kpi_data = Statistic(
type=StatisticType.APPLICATION_KPIS,
data=statistic_kpis,
created_at=datetime.now(),
)
session.add(statistic_kpi_data)

Expand Down Expand Up @@ -103,7 +102,6 @@ def update_statistics(db_provider: Callable[[], Generator[Session, None, None]]
statistic_opt_data = Statistic(
type=StatisticType.MSME_OPT_IN_STATISTICS,
data=statistics_msme_opt_in,
created_at=datetime.now(),
)
session.add(statistic_opt_data)

Expand Down Expand Up @@ -133,7 +131,6 @@ def update_statistics(db_provider: Callable[[], Generator[Session, None, None]]
type=StatisticType.APPLICATION_KPIS,
data=statistic_kpis,
lender_id=lender_id,
created_at=datetime.now(),
)

session.add(statistic_kpi_data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
from alembic import op
from sqlalchemy import text

# revision identifiers, used by Alembic.
revision = "385fb9a01efc"
Expand All @@ -17,7 +18,7 @@
def index_exists(name):
connection = op.get_bind()
result = connection.execute(
"SELECT exists(SELECT 1 from pg_indexes where indexname = '{}') as ix_exists;".format(name)
text("SELECT exists(SELECT 1 from pg_indexes where indexname = :indexname) as ix_exists"), {"indexname": name}
).first()
return result.ix_exists

Expand Down

0 comments on commit a4503b6

Please sign in to comment.