@@ -72,59 +72,25 @@ def fetch_column_field_data(db_path):
72
72
df_column_field = pd .read_sql_query (query , conn )
73
73
return df_column_field
74
74
75
- def fetch_endpoint_summary (db_path ):
76
- conn = sqlite3 .connect (db_path )
75
+ def fetch_endpoint_summary (perf_path ):
76
+ conn = sqlite3 .connect (perf_path )
77
77
query = """
78
- select
79
- e.endpoint,
80
- e.endpoint_url,
81
- s.organisation,
82
- t2.dataset,
83
- t3.status as latest_status,
84
- t3.exception as latest_exception,
85
- substring(e.entry_date, 1, 10) as entry_date,
86
- substring(e.end_date, 1, 10) as end_date,
87
- t2.start_date as latest_resource_start_date
88
- from
89
- endpoint e
90
- inner join source s on s.endpoint = e.endpoint
91
- inner join (
92
- select
93
- *
94
- from
95
- (
96
- SELECT
97
- r.resource,
98
- max(date(r.start_date)) as start_date,
99
- re.endpoint,
100
- rd.dataset,
101
- row_number() over (
102
- partition by re.endpoint
103
- order by
104
- r.start_date desc
105
- ) as rn
106
- FROM
107
- resource r
108
- inner join resource_endpoint re on re.resource = r.resource
109
- inner join resource_dataset rd on rd.resource = r.resource
110
- where r.end_date = ""
111
- GROUP BY
112
- re.endpoint
113
- ) t1
114
- where
115
- t1.rn = 1
116
- ) t2 on e.endpoint = t2.endpoint
117
- inner join (
118
- SELECT
119
- endpoint,
120
- max(date(entry_date)),
121
- status,
122
- exception
123
- FROM
124
- log
125
- GROUP BY
126
- endpoint
127
- ) t3 on e.endpoint = t3.endpoint
78
+ select organisation,
79
+ dataset,
80
+ endpoint,
81
+ endpoint_url,
82
+ resource,
83
+ latest_status,
84
+ latest_exception,
85
+ max(latest_log_entry_date) as latest_log_entry_date,
86
+ endpoint_entry_date as entry_date,
87
+ endpoint_end_date as end_date,
88
+ resource_start_date as latest_resource_start_date,
89
+ resource_end_date
90
+ from reporting_historic_endpoints
91
+ where (endpoint_end_date = '' or endpoint_end_date is null) -- only active endpoints
92
+ and (resource_end_date = '' or resource_end_date is null) -- only active resources
93
+ GROUP BY organisation, dataset, endpoint
128
94
"""
129
95
130
96
df_endpoint_summary = pd .read_sql_query (query , conn )
@@ -270,7 +236,7 @@ def fetch_reporting_data(db_path):
270
236
provision_data = fetch_provision_data (digital_land_db_path )
271
237
issue_data = fetch_issue_data (digital_land_db_path )
272
238
cf_data = fetch_column_field_data (digital_land_db_path )
273
- endpoint_summary_data = fetch_endpoint_summary (digital_land_db_path )
239
+ endpoint_summary_data = fetch_endpoint_summary (performance_db_path )
274
240
reporting_data = fetch_reporting_data (performance_db_path )
275
241
reporting_data ["organisation" ] = reporting_data ["organisation" ].str .replace (
276
242
"-eng" , "" )
0 commit comments