Skip to content

Commit

Permalink
Remove query
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Jan 12, 2024
1 parent bf61fff commit 3ac9370
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/gn_module_monitoring/utils/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from flask import Response, g
from flask.json import jsonify
from geonature.utils.env import DB
from geonature.core.gn_permissions.models import TObjects, PermObject, PermissionAvailable
from geonature.utils.errors import GeoNatureError
from pypnusershub.db.models import User
from gn_module_monitoring.monitoring.models import (
BibTypeSite,
Expand All @@ -17,8 +19,6 @@
)


from geonature.core.gn_permissions.models import TObjects, PermObject, PermissionAvailable
from geonature.utils.errors import GeoNatureError
from marshmallow import Schema
from sqlalchemy import cast, func, text, select
from sqlalchemy.dialects.postgresql import JSON
Expand Down Expand Up @@ -79,15 +79,15 @@ def sort(model, query: Select, sort: str, sort_dir: str) -> Select:
def geojson_query(subquery) -> bytes:
subquery_name = "q"
subquery = subquery.alias(subquery_name)
query = DB.session.query(
query = select(
func.json_build_object(
text("'type'"),
text("'FeatureCollection'"),
text("'features'"),
func.json_agg(cast(func.st_asgeojson(subquery), JSON)),
)
)
result = query.first()
result = DB.session.execute(query.limit(1)).first()
if len(result) > 0:
return result[0]
return b""
Expand Down

0 comments on commit 3ac9370

Please sign in to comment.