feat: switch all timezone naive datetimes to timezone aware
This commit is contained in:
parent
41fc0a73a5
commit
e22abb383c
30 changed files with 322 additions and 226 deletions
|
@ -1,22 +1,22 @@
|
|||
# mypy: ignore-errors
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from flask import Blueprint, render_template
|
||||
from flask.typing import ResponseReturnValue
|
||||
from sqlalchemy import func, and_, desc
|
||||
from sqlalchemy import and_, desc, func
|
||||
from sqlalchemy.orm import aliased
|
||||
|
||||
from app.extensions import db
|
||||
from app.models import Deprecation
|
||||
from app.models.mirrors import Proxy, Origin, Country
|
||||
from app.models.mirrors import Country, Origin, Proxy
|
||||
|
||||
report = Blueprint("report", __name__)
|
||||
|
||||
|
||||
def generate_subqueries():
|
||||
DeprecationAlias = aliased(Deprecation)
|
||||
now = datetime.utcnow()
|
||||
now = datetime.now(tz=timezone.utc)
|
||||
deprecations_24hr_subquery = (
|
||||
db.session.query(
|
||||
DeprecationAlias.resource_id,
|
||||
|
@ -98,7 +98,7 @@ def report_blocks() -> ResponseReturnValue:
|
|||
Proxy.deprecated,
|
||||
Proxy.deprecation_reason
|
||||
).join(Origin, Origin.id == Proxy.origin_id
|
||||
).filter(and_(Proxy.deprecated > datetime.utcnow() - timedelta(days=1),
|
||||
).filter(and_(Proxy.deprecated > datetime.now(tz=timezone.utc) - timedelta(days=1),
|
||||
Proxy.deprecation_reason.like('block_%'))).all()
|
||||
|
||||
return render_template("report_blocks.html.j2",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue