Jul 13 - Optimize code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Main blueprint: landing page, health check, SEO files."""
|
||||
from datetime import datetime
|
||||
from app.utils.time import utcnow
|
||||
from flask import Blueprint, render_template, jsonify, Response, request
|
||||
|
||||
main_bp = Blueprint("main", __name__)
|
||||
@@ -54,7 +55,7 @@ def sitemap():
|
||||
# active listings (last 500 by bump/created for crawl budget)
|
||||
listings = (Listing.query
|
||||
.filter(Listing.status == ListingStatus.active,
|
||||
Listing.expires_at > datetime.utcnow())
|
||||
Listing.expires_at > utcnow())
|
||||
.order_by(Listing.created_at.desc())
|
||||
.limit(500).all())
|
||||
for l in listings:
|
||||
@@ -82,7 +83,7 @@ def category_landing(slug):
|
||||
listings = (Listing.query
|
||||
.filter(Listing.category_id == cat.id,
|
||||
Listing.status == ListingStatus.active,
|
||||
Listing.expires_at > datetime.utcnow())
|
||||
Listing.expires_at > utcnow())
|
||||
.order_by(Listing.created_at.desc())
|
||||
.limit(20).all())
|
||||
return render_template("main/category_landing.html", cat=cat, listings=listings)
|
||||
@@ -97,7 +98,7 @@ def state_landing(state):
|
||||
listings = (Listing.query
|
||||
.filter(Listing.state == state,
|
||||
Listing.status == ListingStatus.active,
|
||||
Listing.expires_at > datetime.utcnow())
|
||||
Listing.expires_at > utcnow())
|
||||
.order_by(Listing.created_at.desc())
|
||||
.limit(20).all())
|
||||
return render_template("main/state_landing.html", state=state, listings=listings)
|
||||
|
||||
Reference in New Issue
Block a user