correction of comparison data show
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
import matplotlib
|
||||
matplotlib.use("Agg")
|
||||
|
||||
@@ -10,6 +11,7 @@ from app.utils.helpers import login_required
|
||||
from app.services.dashboard_service import DashboardService
|
||||
from sqlalchemy import func
|
||||
from app import db
|
||||
from sqlalchemy import tuple_
|
||||
|
||||
# Subcontractor models import
|
||||
from app.models.subcontractor_model import Subcontractor
|
||||
@@ -127,9 +129,7 @@ def get_ra_bills():
|
||||
Laying.subcontractor_id == subcontractor_id
|
||||
).distinct().order_by(Laying.RA_Bill_No).all()
|
||||
|
||||
|
||||
ra_bills = [r[0] for r in results if r[0]]
|
||||
print(results)
|
||||
|
||||
return {"ra_bills": ra_bills}
|
||||
|
||||
@@ -150,7 +150,6 @@ def trench_analysis():
|
||||
|
||||
# Subcontractor Query
|
||||
sub_query = TrenchExcavation.query
|
||||
|
||||
if subcontractor_id:
|
||||
sub_query = sub_query.filter(
|
||||
TrenchExcavation.subcontractor_id == int(subcontractor_id)
|
||||
@@ -161,99 +160,111 @@ def trench_analysis():
|
||||
TrenchExcavation.RA_Bill_No.in_(ra_bill_list)
|
||||
)
|
||||
|
||||
tr_sub = [r.serialize() for r in sub_query.all()]
|
||||
sub_records = sub_query.all()
|
||||
|
||||
sub_keys = [
|
||||
(
|
||||
(r.MH_NO or "").strip().upper(),
|
||||
(r.Location or "").strip().upper()
|
||||
)
|
||||
for r in sub_records
|
||||
]
|
||||
|
||||
|
||||
# Client Query
|
||||
client_query = TrenchExcavationClient.query
|
||||
|
||||
if ra_bill_list:
|
||||
if sub_keys:
|
||||
|
||||
client_query = client_query.filter(
|
||||
TrenchExcavationClient.RA_Bill_No.in_(ra_bill_list)
|
||||
|
||||
tuple_(
|
||||
func.upper(func.trim(TrenchExcavationClient.MH_NO)),
|
||||
func.upper(func.trim(TrenchExcavationClient.Location))
|
||||
).in_(sub_keys)
|
||||
|
||||
)
|
||||
|
||||
tr_client = [r.serialize() for r in client_query.all()]
|
||||
client_records = client_query.all()
|
||||
|
||||
chart_data = [
|
||||
|
||||
{
|
||||
"label": "Marshi 0 to 1.5",
|
||||
"client": total(client_query.all(), "Marshi_Muddy_Slushy_0_to_1_5_total"),
|
||||
"client": total(client_records, "Marshi_Muddy_Slushy_0_to_1_5_total"),
|
||||
"sub": 0
|
||||
},
|
||||
{
|
||||
"label": "Marshi 1.5 to 3.0",
|
||||
"client": total(client_query.all(), "Marshi_Muddy_Slushy_1_5_to_3_0_total"),
|
||||
"client": total(client_records, "Marshi_Muddy_Slushy_1_5_to_3_0_total"),
|
||||
"sub": 0
|
||||
},
|
||||
{
|
||||
"label": "Marshi 3.0-4.5",
|
||||
"client": total(client_query.all(), "Marshi_Muddy_Slushy_3_0_to_4_5_total"),
|
||||
"label": "Marshi 3.0 to 4.5",
|
||||
"client": total(client_records, "Marshi_Muddy_Slushy_3_0_to_4_5_total"),
|
||||
"sub": 0
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Soft Murum 0-1.5",
|
||||
"client": total(client_query.all(), "Soft_Murum_0_to_1_5_total"),
|
||||
"sub": total(sub_query.all(), "Soft_Murum_0_to_1_5_total")
|
||||
"label": "Soft Murum 0 to 1.5",
|
||||
"client": total(client_records, "Soft_Murum_0_to_1_5_total"),
|
||||
"sub": total(sub_records, "Soft_Murum_0_to_1_5_total")
|
||||
},
|
||||
{
|
||||
"label": "Soft Murum 1.5-3.0",
|
||||
"client": total(client_query.all(), "Soft_Murum_1_5_to_3_0_total"),
|
||||
"sub": total(sub_query.all(), "Soft_Murum_1_5_to_3_0_total")
|
||||
"label": "Soft Murum 1.5 to 3.0",
|
||||
"client": total(client_records, "Soft_Murum_1_5_to_3_0_total"),
|
||||
"sub": total(sub_records, "Soft_Murum_1_5_to_3_0_total")
|
||||
},
|
||||
{
|
||||
"label": "Soft Murum 3.0-4.5",
|
||||
"client": total(client_query.all(), "Soft_Murum_3_0_to_4_5_total"),
|
||||
"sub": total(sub_query.all(), "Soft_Murum_3_0_to_4_5_total")
|
||||
"label": "Soft Murum 3.0 to 4.5",
|
||||
"client": total(client_records, "Soft_Murum_3_0_to_4_5_total"),
|
||||
"sub": total(sub_records, "Soft_Murum_3_0_to_4_5_total")
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Hard Murum 0-1.5",
|
||||
"client": total(client_query.all(), "Hard_Murum_0_to_1_5_total"),
|
||||
"sub": total(sub_query.all(), "Hard_Murum_0_to_1_5_total")
|
||||
"label": "Hard Murum 0 to 1.5",
|
||||
"client": total(client_records, "Hard_Murum_0_to_1_5_total"),
|
||||
"sub": total(sub_records, "Hard_Murum_0_to_1_5_total")
|
||||
},
|
||||
{
|
||||
"label": "Hard Murum 1.5+",
|
||||
"client": total(client_query.all(), "Hard_Murum_1_5_to_3_0_total"),
|
||||
"sub": total(sub_query.all(), "Hard_Murum_1_5_and_above_total")
|
||||
"label": "Hard Murum 1.5 to 3.0",
|
||||
"client": total(client_records, "Hard_Murum_1_5_to_3_0_total"),
|
||||
"sub": total(sub_records, "Hard_Murum_1_5_and_above_total")
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Soft Rock 0-1.5",
|
||||
"client": total(client_query.all(), "Soft_Rock_0_to_1_5_total"),
|
||||
"sub": total(sub_query.all(), "Soft_Rock_0_to_1_5_total")
|
||||
"label": "Soft Rock 0 to 1.5",
|
||||
"client": total(client_records, "Soft_Rock_0_to_1_5_total"),
|
||||
"sub": total(sub_records, "Soft_Rock_0_to_1_5_total")
|
||||
},
|
||||
{
|
||||
"label": "Soft Rock 1.5+",
|
||||
"client": total(client_query.all(), "Soft_Rock_1_5_to_3_0_total"),
|
||||
"sub": total(sub_query.all(), "Soft_Rock_1_5_and_above_total")
|
||||
"label": "Soft Rock 1.5 to 3.0",
|
||||
"client": total(client_records, "Soft_Rock_1_5_to_3_0_total"),
|
||||
"sub": total(sub_records, "Soft_Rock_1_5_and_above_total")
|
||||
},
|
||||
|
||||
{
|
||||
"label": "Hard Rock 0-1.5",
|
||||
"client": total(client_query.all(), "Hard_Rock_0_to_1_5_total"),
|
||||
"sub": total(sub_query.all(), "Hard_Rock_0_to_1_5_total")
|
||||
"label": "Hard Rock 0 to 1.5",
|
||||
"client": total(client_records, "Hard_Rock_0_to_1_5_total"),
|
||||
"sub": total(sub_records, "Hard_Rock_0_to_1_5_total")
|
||||
},
|
||||
{
|
||||
"label": "Hard Rock 1.5-3.0",
|
||||
"client": total(client_query.all(), "Hard_Rock_1_5_to_3_0_total"),
|
||||
"sub": total(sub_query.all(), "Hard_Rock_1_5_to_3_0_total")
|
||||
"label": "Hard Rock 1.5 to 3.0",
|
||||
"client": total(client_records, "Hard_Rock_1_5_to_3_0_total"),
|
||||
"sub": total(sub_records, "Hard_Rock_1_5_to_3_0_total")
|
||||
},
|
||||
{
|
||||
"label": "Hard Rock 3.0-4.5",
|
||||
"client": total(client_query.all(), "Hard_Rock_3_0_to_4_5_total"),
|
||||
"sub": total(sub_query.all(), "Hard_Rock_3_0_to_4_5_total")
|
||||
"label": "Hard Rock 3.0 to 4.5",
|
||||
"client": total(client_records, "Hard_Rock_3_0_to_4_5_total"),
|
||||
"sub": total(sub_records, "Hard_Rock_3_0_to_4_5_total")
|
||||
},
|
||||
{
|
||||
"label": "Hard Rock 4.5-6.0",
|
||||
"client": total(client_query.all(), "Hard_Rock_4_5_to_6_0_total"),
|
||||
"sub": total(sub_query.all(), "Hard_Rock_4_5_to_6_0_total")
|
||||
"label": "Hard Rock 4.5 to 6.0",
|
||||
"client": total(client_records, "Hard_Rock_4_5_to_6_0_total"),
|
||||
"sub": total(sub_records, "Hard_Rock_4_5_to_6_0_total")
|
||||
},
|
||||
{
|
||||
"label": "Hard Rock 6.0-7.5",
|
||||
"client": total(client_query.all(), "Hard_Rock_6_0_to_7_5_total"),
|
||||
"sub": total(sub_query.all(), "Hard_Rock_6_0_to_7_5_total")
|
||||
"label": "Hard Rock 6.0 to 7.5",
|
||||
"client": total(client_records, "Hard_Rock_6_0_to_7_5_total"),
|
||||
"sub": total(sub_records, "Hard_Rock_6_0_to_7_5_total")
|
||||
}
|
||||
]
|
||||
|
||||
@@ -263,4 +274,3 @@ def trench_analysis():
|
||||
"sub_qty": [x["sub"] for x in chart_data]
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user