chellow 1724227131.0.0__py3-none-any.whl → 1724318422.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of chellow might be problematic. Click here for more details.

chellow/e/cfd.py CHANGED
@@ -225,46 +225,35 @@ def import_operational_costs_levy(sess, log, set_progress, s):
225
225
  RUN_TYPES = ("II", "SF", "R1", "R2", "R3", "RF", "DF")
226
226
 
227
227
 
228
- def _reconciled_days(log, s, search_from):
229
- runs = {}
230
-
231
- records = [
232
- r
233
- for r in api_records(log, s, "e0e163cb-ba36-416d-83fe-976992d61516")
234
- if r["Settlement_Date"] > search_from
235
- ]
236
- if len(records) > 0:
237
- prev_settlement_date = _parse_date(records[0]["Settlement_Date"])
238
- runs = {}
239
- for record in records:
240
- settlement_date = _parse_date(record["Settlement_Date"])
241
- if settlement_date != prev_settlement_date:
242
- yield prev_settlement_date, runs
243
- runs = {}
244
-
245
- settlement_run_type = record["Settlement_Run_Type"]
246
- runs[settlement_run_type] = record
247
- prev_settlement_date = settlement_date
248
-
249
- yield settlement_date, runs
250
-
251
-
252
- def _reconciled_daily_quarters(log, s, search_from):
253
- quarter = {}
254
- for settlement_date, lcc_runs in _reconciled_days(log, s, search_from):
255
- try:
256
- runs = quarter[settlement_date]
257
- except KeyError:
258
- runs = quarter[settlement_date] = {}
228
+ def _reconciled_quarters(log, s, search_from):
229
+ quarters = {}
230
+
231
+ for record in api_records(log, s, "e0e163cb-ba36-416d-83fe-976992d61516"):
232
+ settlement_date = _parse_date(record["Settlement_Date"])
233
+ if settlement_date > search_from:
234
+ settlement_date_ct = to_ct(settlement_date)
235
+ quarter_start_ct_month = int((settlement_date_ct.month - 1) / 3) * 3 + 1
236
+ quarter_start = to_utc(
237
+ ct_datetime(settlement_date_ct.year, quarter_start_ct_month, 1)
238
+ )
239
+ try:
240
+ quarter = quarters[quarter_start]
241
+ except KeyError:
242
+ quarter = quarters[quarter_start] = {}
259
243
 
260
- for run_type, record in lcc_runs.items():
261
- runs[run_type] = record
244
+ try:
245
+ day = quarter[settlement_date]
246
+ except KeyError:
247
+ day = quarter[settlement_date] = {}
262
248
 
263
- settlement_next_ct = to_ct(settlement_date) + relativedelta(days=1)
249
+ settlement_run_type = record["Settlement_Run_Type"]
250
+ day[settlement_run_type] = record
264
251
 
265
- if settlement_next_ct.month in (1, 4, 7, 10) and settlement_next_ct.day == 1:
266
- yield quarter
267
- quarter = {}
252
+ # Only return complate quarters
253
+ if len(quarters) > 0:
254
+ last_start = sorted(quarters.keys())[-1]
255
+ del quarters[last_start]
256
+ return quarters
268
257
 
269
258
 
270
259
  def import_reconciled_daily_levy_rates(sess, log, set_progress, s):
@@ -277,7 +266,7 @@ def import_reconciled_daily_levy_rates(sess, log, set_progress, s):
277
266
  sess, contract_name, "", {}, to_utc(ct_datetime(1996, 4, 1)), None, {}
278
267
  )
279
268
 
280
- search_from = "1996-04-01"
269
+ search_from = to_utc(ct_datetime(1996, 4, 1))
281
270
  for rs in sess.scalars(
282
271
  select(RateScript)
283
272
  .where(RateScript.contract == contract)
@@ -305,12 +294,12 @@ def import_reconciled_daily_levy_rates(sess, log, set_progress, s):
305
294
  day_ct += relativedelta(days=1)
306
295
 
307
296
  if complete:
308
- search_from = quarter_finish_ct.strftime("%Y-%m-%d")
297
+ search_from = to_utc(quarter_finish_ct)
309
298
  else:
310
299
  break
311
300
 
312
- for quarter in _reconciled_daily_quarters(log, s, search_from):
313
- quarter_start = sorted(quarter.keys())[0]
301
+ for quarter_start, quarter in _reconciled_quarters(log, s, search_from).items():
302
+
314
303
  rs = sess.execute(
315
304
  select(RateScript).where(
316
305
  RateScript.contract == contract,
@@ -5,7 +5,7 @@ import traceback
5
5
 
6
6
  from flask import g, request
7
7
 
8
- from sqlalchemy import null, or_, true
8
+ from sqlalchemy import null, or_, select, true
9
9
  from sqlalchemy.orm import joinedload
10
10
 
11
11
  from chellow.dloads import open_file
@@ -25,36 +25,38 @@ def content(start_date, finish_date, site_id, user_id):
25
25
  writer = csv.writer(f, lineterminator="\n")
26
26
  write_row(
27
27
  writer,
28
- "Site Id",
29
- "Site Name",
30
- "Associated Site Ids",
31
- "Sources",
32
- "Generator Types",
33
- "HH Start Clock-Time",
34
- "Imported kWh",
35
- "Displaced kWh",
36
- "Exported kWh",
37
- "Used kWh",
38
- "Parasitic kWh",
39
- "Generated kWh",
40
- "3rd Party Import",
41
- "3rd Party Export",
42
- "Meter Type",
28
+ "site_id",
29
+ "site_name",
30
+ "associated_site_ids",
31
+ "sources",
32
+ "generator_types",
33
+ "hh_start_clock_time",
34
+ "imported_kwh",
35
+ "displaced_kwh",
36
+ "exported_kwh",
37
+ "used_kwh",
38
+ "parasitic_kwh",
39
+ "generated_kwh",
40
+ "3rd_party_import",
41
+ "3rd_party_export",
42
+ "meter_type",
43
43
  )
44
44
 
45
- sites = sess.query(Site).order_by(Site.code)
45
+ sites_q = select(Site).order_by(Site.code)
46
46
  if site_id is not None:
47
- sites = sites.filter(Site.id == site_id)
47
+ sites_q = sites_q.where(Site.id == site_id)
48
48
 
49
- for site in sites:
49
+ for site in sess.scalars(sites_q):
50
50
  sources = set()
51
51
  generator_types = set()
52
52
  assoc = site.find_linked_sites(sess, start_date, finish_date)
53
53
  metering_type = ""
54
- for era in (
55
- sess.query(Era)
54
+ for era in sess.scalars(
55
+ select(Era)
56
56
  .join(SiteEra)
57
- .filter(
57
+ .join(Supply)
58
+ .join(Source)
59
+ .where(
58
60
  SiteEra.site == site,
59
61
  SiteEra.is_physical == true(),
60
62
  Era.start_date <= finish_date,
@@ -90,9 +92,9 @@ def content(start_date, finish_date, site_id, user_id):
90
92
  sources_str,
91
93
  generators_str,
92
94
  hh["start_date"],
93
- hh["imp_net"],
95
+ hh["imp_grid"],
94
96
  hh["displaced"],
95
- hh["exp_net"],
97
+ hh["exp_grid"],
96
98
  hh["used"],
97
99
  hh["exp_gen"],
98
100
  hh["imp_gen"],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1724227131.0.0
3
+ Version: 1724318422.0.0
4
4
  Summary: Web Application for checking UK energy bills.
5
5
  Project-URL: Homepage, https://github.com/WessexWater/chellow
6
6
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
@@ -18,7 +18,7 @@ chellow/e/bill_importer.py,sha256=7UcnqNlKbJc2GhW9gy8sDp9GuqambJVpZLvbafOZztA,74
18
18
  chellow/e/bmarketidx.py,sha256=C0BaHn2RxIuWH2QzA-OmSP0fbUGvW9tqEUhLnzOEdmA,7968
19
19
  chellow/e/bsuos.py,sha256=hdP9vnOJSuZl46OAkJeUg1XJYvYIBj4J6Sqce1Hy9Vs,15542
20
20
  chellow/e/ccl.py,sha256=30dh_SvlgzsTQPPAJNZWILaMvbeDsv9-P-S1JxS5_SQ,3184
21
- chellow/e/cfd.py,sha256=RvJRLDLY-KvT299a8xF-HRmslPZczqTgJ9C1zBo55U8,14456
21
+ chellow/e/cfd.py,sha256=Gm435c42LFwZx1n-1UY1Tdx6mL1is7E0vRLWQe8RPOo,14184
22
22
  chellow/e/computer.py,sha256=CoYf9SA8zrh1NP_S1jKsfXsaBm5kFcjBbtPUJnx8M9A,67274
23
23
  chellow/e/dno_rate_parser.py,sha256=A5TP6KjyfT5lVWh7dX4SiXRi6wnf2lGv-H_T4Sod8CI,21731
24
24
  chellow/e/duos.py,sha256=nwviRjz-qIt3GxIMHk0hItIT4dtKsxOWq9TUC1z-hO8,30864
@@ -92,7 +92,7 @@ chellow/reports/report_asset_comparison.py,sha256=UN298MHuzyUDUiiZr7F_Ua6SrdVOlF
92
92
  chellow/reports/report_batches.py,sha256=7O5TcB9W1sPKS0LQMsC6sUDzx73X5iyoZE0O3zK91zs,4798
93
93
  chellow/reports/report_bills.py,sha256=AHW6tiZAOE0gXDfencPvemE4zqK6eTqfN8_bWQ4RT5o,3323
94
94
  chellow/reports/report_csv_llfcs.py,sha256=OHSbP64lQ6dlAMcQYgvdANlA4lQyF0iBlwk7V9c9nuo,1944
95
- chellow/reports/report_csv_site_hh_data.py,sha256=T-clGDmYdn0ej7zZfL3kDp4Vyd82WzptxEzxx9KqAZg,4270
95
+ chellow/reports/report_csv_site_hh_data.py,sha256=yWhEoGGyg_ctM8T55raksTPRJ5ycVO6lVfUx5tRBzTQ,4372
96
96
  chellow/reports/report_csv_site_snags.py,sha256=gG2sYQrLoIBwCoMUC8rhmAL7Kffh_rvNb9UOX7cYDko,2668
97
97
  chellow/reports/report_ecoes_comparison.py,sha256=PGDJKI2f6DCVCH0xcp--BzXWAWFfTDGgcKVQnfqxBKg,21653
98
98
  chellow/reports/report_g_monthly_duration.py,sha256=FMMFIWFfGW2Bd9Excpf4LLXXqQ-fbnZZ_KfNa1VaPqA,13034
@@ -365,6 +365,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
365
365
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
366
366
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
367
367
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
368
- chellow-1724227131.0.0.dist-info/METADATA,sha256=TIPwGvUhaCnJygHu9LSLR4zNNY0vJUJlaR2YX7C0gtk,12241
369
- chellow-1724227131.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
370
- chellow-1724227131.0.0.dist-info/RECORD,,
368
+ chellow-1724318422.0.0.dist-info/METADATA,sha256=VR1bg4yGVprAuGnPp_bo8wwpmpcG_tOFHBcamuJ88jo,12241
369
+ chellow-1724318422.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
370
+ chellow-1724318422.0.0.dist-info/RECORD,,