Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

Commit

Permalink
Improvement for DB query
Browse files Browse the repository at this point in the history
  • Loading branch information
emi420 committed Jan 24, 2024
1 parent 13f577e commit b12e20f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions python/dbapi/api/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ def getCount(

if status:
query = "with all_features as ( \
select {0}.osm_id from {0} \
left join changesets c on changeset = c.id \
where {1} {2} {3} {4} {5} \
select {0}.osm_id from {0} \
left join changesets c on changeset = c.id \
where {1} {2} {3} {4} {5} \
), \
validated_features as ( \
select count(distinct(all_features.osm_id)) as count from all_features \
left join validation v on all_features.osm_id = v.osm_id \
where v.status = 'badgeom' \
count_validated_features as ( \
select count(distinct(all_features.osm_id)) as count from all_features \
left join validation v on all_features.osm_id = v.osm_id \
where v.status = 'badgeom' \
), count_features as (\
select count(distinct(all_features.osm_id)) as total from all_features \
) \
select count(distinct(all_features.osm_id)) as total, validated_features.count \
from all_features \
, validated_features group by validated_features.count".format(
select count, total from count_validated_features, count_features".format(
table,
"created_at >= '{0}'".format(dateFrom) if (dateFrom) else "1=1",
"AND created_at <= '{0}'".format(dateTo) if (dateTo) else "",
Expand Down

0 comments on commit b12e20f

Please sign in to comment.