|
@@ -77,21 +77,7 @@ def getkwh(datestart, dateend, timestart, timeend, subset):
|
77
|
77
|
SELECT read_time
|
78
|
78
|
FROM GENERATE_SERIES(%(tsstart)s::timestamp, %(tsend)s::timestamp,
|
79
|
79
|
'30 minutes'::interval) read_time
|
80
|
|
- ) AS tsdata CROSS JOIN
|
81
|
|
- (
|
82
|
|
- SELECT *
|
83
|
|
- FROM
|
84
|
|
- (
|
85
|
|
- SELECT icp_id, COUNT(DISTINCT read_date) AS data_days
|
86
|
|
- FROM coup_prd.coupdatamaster
|
87
|
|
- WHERE read_date >= to_date('01/01/2017','dd/mm/yyyy')
|
88
|
|
- AND read_date < to_date('01/01/2018','dd/mm/yyyy')
|
89
|
|
- AND content_code = 'UN'
|
90
|
|
- AND icp_id LIKE %(subset)s
|
91
|
|
- GROUP BY icp_id
|
92
|
|
- ) AS cir
|
93
|
|
- WHERE data_days >= 360
|
94
|
|
- ) AS qual_icp
|
|
80
|
+ ) AS tsdata CROSS JOIN public.icp_sample
|
95
|
81
|
) AS comb
|
96
|
82
|
LEFT JOIN
|
97
|
83
|
(
|
|
@@ -108,7 +94,9 @@ def getkwh(datestart, dateend, timestart, timeend, subset):
|
108
|
94
|
WHERE a.read_date >= to_date(%(datestart)s,'yyyy-mm-dd')
|
109
|
95
|
and a.read_date < to_date(%(dateend)s,'yyyy-mm-dd')
|
110
|
96
|
and a.content_code ~ ('UN|CN|EG')
|
111
|
|
- AND a.icp_id LIKE %(subset)s
|
|
97
|
+ AND a.icp_id IN (
|
|
98
|
+ SELECT icp_id FROM public.icp_sample
|
|
99
|
+ )
|
112
|
100
|
GROUP BY 1, 2, 3
|
113
|
101
|
) AS coup_tall
|
114
|
102
|
) AS tall_timestamp
|
|
@@ -118,8 +106,8 @@ def getkwh(datestart, dateend, timestart, timeend, subset):
|
118
|
106
|
'datestart': datestart,
|
119
|
107
|
'dateend': dateend,
|
120
|
108
|
'tsstart': timestart,
|
121
|
|
- 'tsend': timeend,
|
122
|
|
- 'subset': subset
|
|
109
|
+ 'tsend': timeend
|
|
110
|
+ # 'subset': subset
|
123
|
111
|
}
|
124
|
112
|
print("Getting data with parameters:")
|
125
|
113
|
print(pdict)
|