Skip to content

Commit f759217

Browse files
authored
Merge pull request #34 from digital-land/overview-of-datasets-update
minor Overview of datasets summary update
2 parents 045e96c + cea8fe3 commit f759217

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

application/data_access/overview/digital_land_queries.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def get_overall_source_counts(groupby=None):
172172
"source",
173173
"INNER JOIN source_pipeline on source.source = source_pipeline.source",
174174
"INNER JOIN organisation on organisation.organisation = replace(source.organisation,'-eng','')",
175+
"WHERE source.end_date is null or source.end_date ==''",
175176
(
176177
f"GROUP BY {groupby_options.get(groupby)}"
177178
if groupby and groupby_options.get(groupby)
@@ -193,7 +194,7 @@ def get_grouped_source_counts(organisation=None, **kwargs):
193194

194195

195196
def fetch_total_resource_count():
196-
sql = "select count(distinct resource) from resource"
197+
sql = "select count(distinct resource) from resource where end_date is null or end_date ==''"
197198
rows = get_datasette_query("digital-land", f"""{sql}""")
198199

199200
return rows.iloc[0][0] if len(rows) > 0 else 0

application/data_access/overview/entity_queries.py

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import json
2+
import urllib.request
3+
14
from application.data_access.datasette_utils import get_datasette_query
25
from application.data_access.overview.api_queries import get_organisation_entity_number
36
from application.utils import split_organisation_id
@@ -32,19 +35,11 @@ def get_grouped_entity_count(dataset=None, organisation_entity=None):
3235
return {}
3336

3437

35-
def get_total_entity_count():
36-
sql = "select count(*) from lookup"
37-
row = get_datasette_query("digital-land", sql)
38-
39-
return row.iloc[0][0] if len(row) > 0 else 0
40-
41-
4238
def get_entity_count(pipeline=None):
43-
if pipeline is not None:
44-
sql = "select count(*) from lookup WHERE prefix = :pipeline"
45-
row = get_datasette_query("digital-land", sql, {"pipeline": pipeline})
46-
return row.iloc[0][0] if len(row) > 0 else 0
47-
return get_total_entity_count()
39+
url = f"https://www.planning.data.gov.uk/entity.json{f'?prefix={pipeline}' if pipeline else ''}"
40+
with urllib.request.urlopen(url) as response:
41+
data = json.load(response)
42+
return data["count"]
4843

4944

5045
def get_organisation_entity_count(organisation, dataset=None):

application/templates/overview/performance.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h2>{{ entity_count|commanum }}</h2>
4242
<div class="govuk-grid-column-one-quarter">
4343
<div class="app-data-item">
4444
<p class="govuk-body app-data-item__label">Datasets</p>
45-
<h2>{{ datasets_with_data_count }}<h2">/{{ datasets|length }}</h2></h2>
45+
<h2>{{ datasets|length }}</h2>
4646
</div>
4747
</div>
4848
<div class="govuk-grid-column-one-quarter">

0 commit comments

Comments
 (0)