[go: up one dir, main page]

0% found this document useful (0 votes)
10 views4 pages

Important Script

The document contains a series of SQL queries executed by a user named 'smtuser', focusing on retrieving data from various tables related to product serial mappings and stage reports. It includes commands to terminate backend processes and a Python script that processes stage report data using pandas, filtering results by date and pass/fail status. The script aggregates the data for reporting on tested and passed serial numbers across specified date ranges.

Uploaded by

ayushman292140
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Important Script

The document contains a series of SQL queries executed by a user named 'smtuser', focusing on retrieving data from various tables related to product serial mappings and stage reports. It includes commands to terminate backend processes and a Python script that processes stage report data using pandas, filtering results by date and pass/fail status. The script aggregates the data for reporting on tested and passed serial numbers across specified date ranges.

Uploaded by

ayushman292140
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

284640 | 6 days 00:51:31.796139 | smtuser | SELECT "stageapp_serialmapping".

"id",
"stageapp_serialmapping"."product_id", "stageapp_serialmapping"."serial_top",
"stageapp_serialmapping"."start_top", "stageapp_serialmapping"."serial_bottom",
"stageapp_serialmapping"."start_bottom", "stageapp_serialmapping"."ct_label",
"stageapp_serialmapping"."child_top", "stageapp_serialmapping"."child_bottom",
"stageapp_serialmapping"."work_order" FROM "stageapp_serialmapping" WHERE
"stageapp_serialmapping"."ct_label" IN ('PYKVD0ACOJF01P', 'PYKVD0ACOJF01R',
'PYKVD0ACOJF01G', 'PYKVD0ACOJF01S', 'PYKVD0ACOJF01Z', 'PYKVD0ACOJF01Q',
'PYKVD0ACOJF023', 'PYKVD0ACOJF021', 'PYKVD0ACOJF01Y', 'PYKVD0ACOJF028',
'PYKVD0ACOJF018', 'PYKVD0ACOJF011', 'PYKVD0ACOJF01V', 'PYKVD0ACOJF01B',
'PYKVD0ACOJF01W', 'PYKVD0ACOJF01X', 'PYKVD0ACOJF01M', 'PYKVD0ACOJF01K',
'PYKVD0ACOJF024', 'PYKVD0ACOJF01N', 'PYKVD0ACOJF00K', 'PYKVD0ACOJF007',
'PYKVD0ACOJF00H', 'PYKVD0ACOJF01D', 'PYKVD0ACOJF01F')
998266 | 5 days 14:34:28.125872 | smtuser | SELECT "stageapp_line"."id",
"stageapp_line"."product_id", "stageapp_line"."line_name",
"stageapp_line"."line_no", "stageapp_line"."aoi_machine_no",
"stageapp_line"."is_active", "stageapp_line"."ip_address",
"stageapp_line"."reflow_machine_ip", "stageapp_line"."reflow_machine_port" FROM
"stageapp_line" WHERE "stageapp_line"."line_name" = 'line10' LIMIT 21
1017615 | 5 days 14:17:26.312852 | smtuser | SELECT "stageapp_line"."id",
"stageapp_line"."product_id", "stageapp_line"."line_name",
"stageapp_line"."line_no", "stageapp_line"."aoi_machine_no",
"stageapp_line"."is_active", "stageapp_line"."ip_address",
"stageapp_line"."reflow_machine_ip", "stageapp_line"."reflow_machine_port" FROM
"stageapp_line" WHERE "stageapp_line"."line_name" = 'line10' LIMIT 21
1615052 | 02:04:09.103912 | smtuser | select * from reflow_reworkreport
where serial_no='PYKVD0ACOJF00B';
1784969 | 00:29:34.122067 | smtuser | SELECT c.oid::pg_catalog.regclass,
pg_catalog.pg_get_expr(c.relpartbound, c.oid), c.relkind FROM
pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND
i.inhparent = '25084' ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) =
'DEFAULT', c.oid::pg_catalog.regclass::pg_catalog.text;
1777120 | 00:06:04.03059 | smtuser | select distinct on (serial_no)
serial_no,created_at,stage_name from (select serial_no ,TO_CHAR(created_at at time
zone 'Asia/Kolkata','YYYY-MM-DD')as created_at,stage_name from stageapp_stagereport
where work_order='1100059443') s;
1814308 | 00:00:25.871732 | smtuser | select distinct on (serial_no)
serial_no,created_at,stage_name from (select serial_no ,TO_CHAR(created_at at time
zone 'Asia/Kolkata','YYYY-MM-DD')as created_at,stage_name from stageapp_stagereport
where work_order='1100059443') sq;
1766273 | 00:00:05.564274 | smtuser | SELECT "stageapp_line"."id",
"stageapp_line"."product_id", "stageapp_line"."line_name",
"stageapp_line"."line_no", "stageapp_line"."aoi_machine_no",
"stageapp_line"."is_active", "stageapp_line"."ip_address",
"stageapp_line"."reflow_machine_ip", "stageapp_line"."reflow_machine_port" FROM
"stageapp_line" WHERE "stageapp_line"."line_name" = 'line9' LIMIT 21
(13 rows)

# for configuring pcb only in bottom side of line


+ request.data["line_name"]="one"

SELECT pg_terminate_backend(284640);
SELECT pg_terminate_backend(998266);
SELECT pg_terminate_backend(1017615);
SELECT pg_terminate_backend(1615052);
SELECT pg_terminate_backend(1784969);
SELECT pg_terminate_backend(1777120);
SELECT pg_terminate_backend(1814308);
SELECT pg_terminate_backend(1766273);

import pandas as pd
from django.db import connection
from stageapp.models import Stage
query = """select stage_id, serial_no, result, TO_CHAR(created_at AT TIME ZONE
'Asia/Kolkata','YYYY-MM-DD HH24') as created_at,created_at AT TIME ZONE
'Asia/Kolkata' as create_time from stageapp_stagereport WHERE
work_order='1100059443'"""
df = pd.read_sql(query, connection)
df['created_at'] = pd.to_datetime(df['created_at'])
april_22 = df[(df.created_at >= '2024-04-22 06:00:00') & (df.created_at < '2024-04-
23 17:00:00')]
april_23 = df[(df.created_at >= '2024-04-23 17:00:00') & (df.created_at < '2024-04-
24 17:00:00')]
april_24 = df[(df.created_at >= '2024-04-24 17:00:00') & (df.created_at < '2024-04-
25 17:00:00')]
april_25 = df[(df.created_at >= '2024-04-25 17:00:00') & (df.created_at < '2024-04-
26 17:00:00')]
april_26 = df[(df.created_at >= '2024-04-26 17:00:00') & (df.created_at < '2024-04-
27 17:00:00')]
april_27 = df[(df.created_at >= '2024-04-27 17:00:00') & (df.created_at < '2024-04-
28 17:00:00')]
april_28 = df[(df.created_at >= '2024-04-28 17:00:00') & (df.created_at < '2024-04-
29 17:00:00')]
april_29 = df[(df.created_at >= '2024-04-29 17:00:00') & (df.created_at < '2024-04-
30 17:00:00')]
april_30 = df[(df.created_at >= '2024-04-30 17:00:00') & (df.created_at < '2024-05-
01 17:00:00')]
may_1 = df[(df.created_at >= '2024-05-01 17:00:00') & (df.created_at < '2024-05-02
17:00:00')]
may_2 = df[(df.created_at >= '2024-05-02 17:00:00') & (df.created_at < '2024-05-03
17:00:00')]
april_22_pass = df[(df.created_at >= '2024-04-22 06:00:00') & (df.created_at <
'2024-04-23 17:00:00') & (df.result==True)]
april_23_pass = df[(df.created_at >= '2024-04-23 17:00:00') & (df.created_at <
'2024-04-24 17:00:00') & (df.result==True)]
april_24_pass = df[(df.created_at >= '2024-04-24 17:00:00') & (df.created_at <
'2024-04-25 17:00:00') & (df.result==True)]
april_25_pass = df[(df.created_at >= '2024-04-25 17:00:00') & (df.created_at <
'2024-04-26 17:00:00') & (df.result==True)]
april_26_pass = df[(df.created_at >= '2024-04-26 17:00:00') & (df.created_at <
'2024-04-27 17:00:00') & (df.result==True)]
april_27_pass = df[(df.created_at >= '2024-04-27 17:00:00') & (df.created_at <
'2024-04-28 17:00:00') & (df.result==True)]
april_28_pass = df[(df.created_at >= '2024-04-28 17:00:00') & (df.created_at <
'2024-04-29 17:00:00') & (df.result==True)]
april_29_pass = df[(df.created_at >= '2024-04-29 17:00:00') & (df.created_at <
'2024-04-30 17:00:00') & (df.result==True)]
april_30_pass = df[(df.created_at >= '2024-04-30 17:00:00') & (df.created_at <
'2024-05-01 17:00:00') & (df.result==True)]
may_1_pass = df[(df.created_at >= '2024-05-01 17:00:00') & (df.created_at < '2024-
05-02 17:00:00') & (df.result==True)]
may_2_pass = df[(df.created_at >= '2024-05-02 17:00:00') & (df.created_at < '2024-
05-03 17:00:00') & (df.result==True)]
april_22_fail = df[(df.created_at >= '2024-04-22 06:00:00') & (df.created_at <
'2024-04-23 17:00:00') & (df.result==False)]
april_23_fail = df[(df.created_at >= '2024-04-23 17:00:00') & (df.created_at <
'2024-04-24 17:00:00') & (df.result==False)]
april_24_fail = df[(df.created_at >= '2024-04-24 17:00:00') & (df.created_at <
'2024-04-25 17:00:00') & (df.result==False)]
april_25_fail = df[(df.created_at >= '2024-04-25 17:00:00') & (df.created_at <
'2024-04-26 17:00:00') & (df.result==False)]
april_26_fail = df[(df.created_at >= '2024-04-26 17:00:00') & (df.created_at <
'2024-04-27 17:00:00') & (df.result==False)]
april_27_fail = df[(df.created_at >= '2024-04-27 17:00:00') & (df.created_at <
'2024-04-28 17:00:00') & (df.result==False)]
april_28_fail = df[(df.created_at >= '2024-04-28 17:00:00') & (df.created_at <
'2024-04-29 17:00:00') & (df.result==False)]
april_29_fail = df[(df.created_at >= '2024-04-29 17:00:00') & (df.created_at <
'2024-04-30 17:00:00') & (df.result==False)]
april_30_fail = df[(df.created_at >= '2024-04-30 17:00:00') & (df.created_at <
'2024-05-01 17:00:00') & (df.result==False)]
may_1_fail = df[(df.created_at >= '2024-05-01 17:00:00') & (df.created_at < '2024-
05-02 17:00:00') & (df.result==False)]
may_2_fail = df[(df.created_at >= '2024-05-02 17:00:00') & (df.created_at < '2024-
05-03 17:00:00') & (df.result==False)]
data = []
data.append(["","2024-04-22 06:00:00 to 2024-04-23 17:00:00","2024-04-23 17:00:00
to 2024-04-24 17:00:00","2024-04-24 17:00:00 to 2024-04-25 17:00:00","2024-04-25
17:00:00 to 2024-04-26 17:00:00","2024-04-26 17:00:00 to 2024-04-27
17:00:00","2024-04-27 17:00:00 to 2024-04-28 17:00:00","2024-04-28 17:00:00 to
2024-04-29 17:00:00","2024-04-29 17:00:00 to 2024-04-30 17:00:00","2024-04-30
17:00:00 to 2024-05-01 17:00:00","2024-05-01 17:00:00 to 2024-05-02
17:00:00","2024-05-02 17:00:00 to 2024-05-03 17:00:00"])
stages = Stage.objects.filter(offline_stages=False).order_by("id").values('name',
'id', 'fail_count')
for _data in stages:
data.append([_data["name"],"","","","","","","","","","",""])
data.append(["Total Tested",april_22[april_22.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_23[april_23.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_24[april_24.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_25[april_25.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_26[april_26.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_27[april_27.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_28[april_28.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_29[april_29.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_30[april_30.stage_id ==
_data["id"]].serial_no.unique().shape[0],may_1[may_1.stage_id ==
_data["id"]].serial_no.unique().shape[0],may_2[may_2.stage_id ==
_data["id"]].serial_no.unique().shape[0]])
data.append(["Total Pass",april_22_pass[april_22_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_23_pass[april_23_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_24_pass[april_24_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_25_pass[april_25_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_26_pass[april_26_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_27_pass[april_27_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_28_pass[april_28_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_29_pass[april_29_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_30_pass[april_30_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],may_1_pass[may_1_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0],may_2_pass[may_2_pass.stage_id ==
_data["id"]].serial_no.unique().shape[0]])
data.append(["Total Fail",april_22_fail[april_22_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_23_fail[april_23_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_24_fail[april_24_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_25_fail[april_25_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_26_fail[april_26_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_27_fail[april_27_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_28_fail[april_28_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_29_fail[april_29_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],april_30_fail[april_30_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],may_1_fail[may_1_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0],may_2_fail[may_2_fail.stage_id ==
_data["id"]].serial_no.unique().shape[0]])
print(data)

You might also like