chellow 1737970902.0.0__py3-none-any.whl → 1738075773.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/gas/views.py CHANGED
@@ -18,8 +18,8 @@ from flask import (
18
18
  request,
19
19
  )
20
20
 
21
- from sqlalchemy import false, func, select, text, true
22
- from sqlalchemy.orm import joinedload
21
+ from sqlalchemy import false, func, null, select, text, true
22
+ from sqlalchemy.orm import aliased, joinedload
23
23
 
24
24
 
25
25
  from werkzeug.exceptions import BadRequest
@@ -1547,12 +1547,38 @@ def batch_csv_get(g_batch_id):
1547
1547
 
1548
1548
  @gas.route("/supplier_contracts")
1549
1549
  def supplier_contracts_get():
1550
- contracts = g.sess.execute(
1550
+ GRateScriptAliasFinish = aliased(GRateScript)
1551
+
1552
+ current_contracts = g.sess.scalars(
1551
1553
  select(GContract)
1552
- .where(GContract.is_industry == false())
1554
+ .join(
1555
+ GRateScriptAliasFinish,
1556
+ GContract.finish_g_rate_script_id == GRateScriptAliasFinish.id,
1557
+ )
1558
+ .where(
1559
+ GContract.is_industry == false(),
1560
+ GRateScriptAliasFinish.finish_date == null(),
1561
+ )
1553
1562
  .order_by(GContract.name)
1554
- ).scalars()
1555
- return render_template("supplier_contracts.html", contracts=contracts)
1563
+ )
1564
+ ended_contracts = g.sess.scalars(
1565
+ select(GContract)
1566
+ .join(
1567
+ GRateScriptAliasFinish,
1568
+ GContract.finish_g_rate_script_id == GRateScriptAliasFinish.id,
1569
+ )
1570
+ .where(
1571
+ GContract.is_industry == false(),
1572
+ GRateScriptAliasFinish.finish_date != null(),
1573
+ )
1574
+ .order_by(GContract.name)
1575
+ )
1576
+
1577
+ return render_template(
1578
+ "supplier_contracts.html",
1579
+ current_contracts=current_contracts,
1580
+ ended_contracts=ended_contracts,
1581
+ )
1556
1582
 
1557
1583
 
1558
1584
  @gas.route("/supplier_contracts/<int:contract_id>")
@@ -772,7 +772,7 @@ def content(scenario_props, base_name, user_id, compression, now):
772
772
  else:
773
773
  forecast_from = to_utc(forecast_from)
774
774
 
775
- sites = sess.query(Site).distinct().order_by(Site.code)
775
+ base_site_set = set()
776
776
 
777
777
  mpan_cores = scenario_props.get("mpan_cores")
778
778
  supply_ids = None
@@ -788,12 +788,14 @@ def content(scenario_props, base_name, user_id, compression, now):
788
788
  else:
789
789
  base_name.append("mpan_cores")
790
790
 
791
- sites = (
792
- sites.join(SiteEra)
791
+ for site in sess.scalars(
792
+ select(Site)
793
+ .join(SiteEra)
793
794
  .join(Era)
794
795
  .join(Supply)
795
796
  .where(Supply.id.in_(supply_ids))
796
- )
797
+ ):
798
+ base_site_set.add(site.id)
797
799
 
798
800
  site_codes = scenario_props.get("site_codes")
799
801
  if site_codes is not None:
@@ -802,7 +804,10 @@ def content(scenario_props, base_name, user_id, compression, now):
802
804
  base_name.append(site_codes[0])
803
805
  else:
804
806
  base_name.append("sitecodes")
805
- sites = sites.where(Site.code.in_(site_codes))
807
+
808
+ for site_code in site_codes:
809
+ site = Site.get_by_code(sess, site_code)
810
+ base_site_set.add(site.id)
806
811
 
807
812
  user = User.get_by_id(sess, user_id)
808
813
 
@@ -969,7 +974,6 @@ def content(scenario_props, base_name, user_id, compression, now):
969
974
  site_rows.append(site_header_titles + summary_titles)
970
975
  era_rows.append(era_titles)
971
976
 
972
- sites = sites.all()
973
977
  normal_reads = set()
974
978
 
975
979
  for month_start, month_finish in month_pairs:
@@ -980,7 +984,40 @@ def content(scenario_props, base_name, user_id, compression, now):
980
984
  else:
981
985
  data_source_bill = None
982
986
  org_month_data = defaultdict(int)
983
- for site in sites:
987
+
988
+ if len(base_site_set) > 0:
989
+ site_set = base_site_set
990
+ else:
991
+ site_set = set()
992
+ for site in sess.scalars(
993
+ select(Site)
994
+ .join(SiteEra)
995
+ .join(Era)
996
+ .where(
997
+ Era.start_date <= month_finish,
998
+ or_(
999
+ Era.finish_date == null(),
1000
+ Era.finish_date >= month_start,
1001
+ ),
1002
+ )
1003
+ ):
1004
+ site_set.add(site.id)
1005
+ for site in sess.scalars(
1006
+ select(Site)
1007
+ .join(SiteEra)
1008
+ .join(Era)
1009
+ .join(Supply)
1010
+ .join(Bill)
1011
+ .where(
1012
+ Bill.start_date <= month_finish,
1013
+ Bill.finish_date >= month_start,
1014
+ )
1015
+ ):
1016
+ site_set.add(site.id)
1017
+
1018
+ for site in sess.scalars(
1019
+ select(Site).where(Site.id.in_(site_set)).order_by(Site.code)
1020
+ ):
984
1021
  if by_hh:
985
1022
  sf = [
986
1023
  (d, d)
@@ -11,6 +11,29 @@
11
11
  {% block content %}
12
12
 
13
13
  <table>
14
+ <caption>Current Contracts</caption>
15
+ <thead>
16
+ <tr>
17
+ <th>Name</th>
18
+ <th>Start Date</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ {% for g_contract in current_contracts %}
23
+ <tr>
24
+ <td>
25
+ <a href="/g/supplier_contracts/{{g_contract.id}}">{{g_contract.name}}</a>
26
+ </td>
27
+ <td>
28
+ {{g_contract.start_g_rate_script.start_date|hh_format}}
29
+ </td>
30
+ </tr>
31
+ {% endfor %}
32
+ </tbody>
33
+ </table>
34
+
35
+ <table>
36
+ <caption>Ended Contracts</caption>
14
37
  <thead>
15
38
  <tr>
16
39
  <th>Name</th>
@@ -19,7 +42,7 @@
19
42
  </tr>
20
43
  </thead>
21
44
  <tbody>
22
- {% for g_contract in contracts %}
45
+ {% for g_contract in ended_contracts %}
23
46
  <tr>
24
47
  <td>
25
48
  <a href="/g/supplier_contracts/{{g_contract.id}}">{{g_contract.name}}</a>
@@ -34,5 +57,4 @@
34
57
  {% endfor %}
35
58
  </tbody>
36
59
  </table>
37
-
38
60
  {% endblock %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chellow
3
- Version: 1737970902.0.0
3
+ Version: 1738075773.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)
@@ -72,7 +72,7 @@ chellow/gas/cv.py,sha256=4cdYYQ8Qak6NeYdBCB4YaQ0jX8-UkaydIIdibCQuXxM,7344
72
72
  chellow/gas/dn_rate_parser.py,sha256=Mq8rAcUEUxIQOks59bsCKl8GrefvoHbrTCHqon9N0z0,11340
73
73
  chellow/gas/engine.py,sha256=d2rR1y8b3u2QhmfqyFwwLu_loeZxY_3WwwtDyGJfam0,25282
74
74
  chellow/gas/transportation.py,sha256=Bkg8TWOs-v0ES-4qqwbleiOhqbE_t2KauUx9JYMZELM,5300
75
- chellow/gas/views.py,sha256=1_bPHA6i0BlQmQ6YhQaGSMnIm-81dO3ksHW5uL2n2NE,59003
75
+ chellow/gas/views.py,sha256=7ObrqTR-z6cRGpBcilUroSKL9C0hGfOo4GcCnGhBuYU,59737
76
76
  chellow/reports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
77
  chellow/reports/report_109.py,sha256=Exb-FQ5f70-ier_h15CgHGysQ7vJ7k3gFZ1001zM3iM,11171
78
78
  chellow/reports/report_111.py,sha256=o_wWyrtmxpTnmT9DVlsG5h5wdm3JqojirRlx_7W5_kQ,28787
@@ -84,7 +84,7 @@ chellow/reports/report_219.py,sha256=3Zs16ka6dWWY_lCDoA-ZFrlPb4vHk1LQoa2yrlTMntA
84
84
  chellow/reports/report_231.py,sha256=WARLztV2HzBFSi5_xvY_DTXVyuBBbBYiU0RazfjKw-Y,5270
85
85
  chellow/reports/report_233.py,sha256=qJdPFuBgQAWD24BsljgGJ44L_RGdHOA1RqsxGjTWhFc,4975
86
86
  chellow/reports/report_241.py,sha256=lfivElRkV_CZAhck0rxAuhqzgponj3aWwmwGMNQvUxg,5343
87
- chellow/reports/report_247.py,sha256=Hhhk0XcDdS3SaA-BJxw6BtN7mOhdKjBdtBNV7zqqaAI,44509
87
+ chellow/reports/report_247.py,sha256=A74EfUihmV4Pa3NyrJfkf28HJn61Ai4wN694ETfbO4Q,45894
88
88
  chellow/reports/report_29.py,sha256=ZXnq6Kg5on-IPquUsH4bn46mBVESY_WhwqDWZPXOJwo,2695
89
89
  chellow/reports/report_291.py,sha256=BnWtxe0eWN2QKKWpwjs5-RI5LbReBKL119QbkrkNhV8,7478
90
90
  chellow/reports/report_33.py,sha256=lt1EN_LNx6u-AgdaS3YRkPMZA33JgMcELolHF4oJUMw,16689
@@ -364,7 +364,7 @@ chellow/templates/g/reports.html,sha256=u3i8fKSdMYxRUAjBF31OhqHnK82WyOMyl_6X2at6
364
364
  chellow/templates/g/supplier_contract.html,sha256=SutQmo9VhqpjWIA6IuloAEzq54u9ng-f4b3wOzY2Enc,2144
365
365
  chellow/templates/g/supplier_contract_add.html,sha256=jLE-CwZ3Dt8hIkAGJ53hyjzIJPIeBkvNqQ5uMe9tSf0,656
366
366
  chellow/templates/g/supplier_contract_edit.html,sha256=p_IL0cKT9s-lV2W1kTZp9U1b7QdXzIiTsaVuVh4rztA,1119
367
- chellow/templates/g/supplier_contracts.html,sha256=GGS47UblUNZA5dPvvjE5SDPbFFfUCQzzHWN4X3_lvZM,710
367
+ chellow/templates/g/supplier_contracts.html,sha256=Xzr0BRs92NT7haPXOgSS0zdw5trLdSrbv1pPqJMi6X8,1176
368
368
  chellow/templates/g/supplier_rate_script.html,sha256=e4dwskWTQcLv6qyX150VUeuaUvE4NuMWd27Zus6fHZ8,1283
369
369
  chellow/templates/g/supplier_rate_script_add.html,sha256=zMjTkjupOsHFu-peUXL4IKjjc2OaSL-2ah4T9OdKp_o,620
370
370
  chellow/templates/g/supplier_rate_script_edit.html,sha256=GoUqXf52gWEH1iApmNdxOcKLItzpA-o7iQPQ1_in9BA,1950
@@ -376,6 +376,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
376
376
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
377
377
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
378
378
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
379
- chellow-1737970902.0.0.dist-info/METADATA,sha256=-PX-L_InK77KEH_JUnv2jKfvvmY1VKsDdHOZsJWuj5Y,12204
380
- chellow-1737970902.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
381
- chellow-1737970902.0.0.dist-info/RECORD,,
379
+ chellow-1738075773.0.0.dist-info/METADATA,sha256=aGKA0SwgygLVeXzxGpu6ckA2rnsJ-HFnrizVUUw8IbI,12204
380
+ chellow-1738075773.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
381
+ chellow-1738075773.0.0.dist-info/RECORD,,