I have model as follows:
class BlogModel(BaseModel):
class Meta:
table_name = "blogs"
updated_at = DateTimeTZField(default=datetime.datetime.utcnow)
frequency = CharField(choices=REPORT_FREQUENCY, default="once")
status = CharField(default="active")
deleted_at = DateTimeTZField(null=True)
My try (but get error):
now = datetime.now(tz.UTC)
scheduled_reports = BlogModel.select().where(
BlogModel.deleted_at.is_null(True),
BlogModel.status == "active",
BlogModel.frequency != "once",
(
BlogModel.updated_at.cast(int) + get_timestamp_from_frequency(BlogModel.frequency)) > now,
)
I want to add updated_at with timestamp value and check if it is greater than now value.
Is there any specific way to query in single database hit? I know I can iterate over the rows and filter out the result using python after fetching from db. But I want to filter before fetching any row from database