Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
oee-services
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
harshavardhan.c
oee-services
Commits
53cdbc0e
Commit
53cdbc0e
authored
May 25, 2022
by
shreya.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format
parent
979fdf6c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
23 deletions
+25
-23
scripts/core/handlers/oee_handlers.py
scripts/core/handlers/oee_handlers.py
+10
-13
scripts/services/oee_services.py
scripts/services/oee_services.py
+15
-10
No files found.
scripts/core/handlers/oee_handlers.py
View file @
53cdbc0e
...
...
@@ -12,7 +12,7 @@ from scripts.schemas import mongo_schema
from
scripts.constants.db_connections
import
mongo_client
class
Oee
_
Services
:
class
OeeServices
:
def
__init__
(
self
,
project_id
=
Get_Project_Id
.
project_id
):
try
:
self
.
connect
=
collection_constants
(
mongo_client
=
mongo_client
)
...
...
@@ -23,12 +23,12 @@ class Oee_Services:
logger
.
exception
(
"Error while connecting to mongodb"
)
raise
def
oee_tag
_mapping
(
self
,
oee_tag_mappin
g_list
:
Oee_Tag_Mapping_List
):
def
oee_tag
(
self
,
oee_ta
g_list
:
Oee_Tag_Mapping_List
):
try
:
insert_json
=
{
"hierarchy"
:
oee_tag_
mapping_
list
.
hierarchy
,
"project_id"
:
oee_tag_
mapping_
list
.
project_id
,
"meta"
:
oee_tag_
mapping_
list
.
project_id
,
"oee_tag_mapping"
:
oee_tag_
mapping_
list
.
oee_tag_mapping
insert_json
=
{
"hierarchy"
:
oee_tag_list
.
hierarchy
,
"project_id"
:
oee_tag_list
.
project_id
,
"meta"
:
oee_tag_list
.
project_id
,
"oee_tag_mapping"
:
oee_tag_list
.
oee_tag_mapping
}
result
=
self
.
connect
.
insert_one
(
data
=
insert_json
)
if
result
:
...
...
@@ -42,9 +42,9 @@ class Oee_Services:
logger
.
exception
(
"Error occurred while inserting data"
)
raise
def
get_oee_tag
_mapping
(
self
,
get_oee_tag
:
Get_Oee_Tag
):
def
get_oee_tag
(
self
,
get_oee_tag
:
Get_Oee_Tag
):
try
:
return_json
=
{
"message"
:
"failure"
,
"status"
:
"failure"
,
"data"
:
"data not found"
}
query
=
{
'project_id'
:
get_oee_tag
.
project_id
}
skips
=
get_oee_tag
.
page_size
*
(
get_oee_tag
.
page_num
-
1
)
no_of_documents
=
self
.
connect
.
count_documents
(
query
=
query
)
...
...
@@ -56,11 +56,8 @@ class Oee_Services:
# return_json["endOfrecords"] = True
return
result
except
Exception
as
e
:
tb
=
traceback
.
format_exc
()
logger
.
exception
(
e
)
logger
.
exception
(
tb
)
logger
.
exception
(
f
"Exception occurred while fetching data as {e}"
)
raise
raise
logger
.
exception
(
f
"Exception occurred while fetching data as {e.args}"
)
def
delete_oee_tags
(
self
,
project_id
:
Get_Project_Id
):
try
:
...
...
scripts/services/oee_services.py
View file @
53cdbc0e
...
...
@@ -3,26 +3,31 @@ from scripts.logging import logger
from
scripts.constants
import
Endpoints
from
scripts.schemas.batch_oee
import
GetOeeServices
from
scripts.core.handlers
import
oee_handlers
import
traceback
from
scripts.schemas.response_models
import
DefaultFailureResponse
oee_services
=
APIRouter
(
prefix
=
Endpoints
.
oee_services
,
tags
=
[
"OEE Calculator"
])
@
oee_services
.
post
(
Endpoints
.
oee_services
)
async
def
oee_tag
_mapping
(
oee_tag_mapping_list
:
GetOeeServices
):
async
def
oee_tag
(
oee_tag_mapping_list
:
GetOeeServices
):
try
:
tag_mapping
=
oee_tag_mapping_list
.
dict
()
result
=
oee_handlers
.
Oee
_Services
.
oee_tag_mappin
g
(
oee_tag_mapping_list
)
result
=
oee_handlers
.
Oee
Services
.
oee_ta
g
(
oee_tag_mapping_list
)
return
result
except
Exception
as
e
:
raise
logger
.
exception
(
"Exception occurred while inserting data"
)
tb
=
traceback
.
format_exc
()
logger
.
exception
(
e
)
logger
.
exception
(
tb
)
return
DefaultFailureResponse
(
error
=
e
.
args
)
.
dict
()
@
oee_services
.
post
(
Endpoints
.
oee_services
)
async
def
get_oee_tag
_mapping
(
get_oee_tags
:
GetOeeServices
):
async
def
get_oee_tag
(
get_oee_tags
:
GetOeeServices
):
try
:
get_oee_tags
=
get_oee_tags
.
dict
()
return_json
=
oee_handlers
.
Oee
_Services
.
get_oee_tag_mappin
g
(
get_oee_tags
)
return_json
=
oee_handlers
.
Oee
Services
.
get_oee_ta
g
(
get_oee_tags
)
return
return_json
except
Exception
as
e
:
...
...
@@ -30,10 +35,10 @@ async def get_oee_tag_mapping(get_oee_tags: GetOeeServices):
@
oee_services
.
post
(
Endpoints
.
oee_services
)
async
def
delete_oee_tag
ging
(
delete_oee_tags
:
GetOeeServices
):
async
def
delete_oee_tag
(
delete_oee_tags
:
GetOeeServices
):
try
:
delete_oee_tags
=
delete_oee_tags
.
dict
()
return_json
=
oee_handlers
.
Oee
_
Services
.
delete_oee_tags
(
project_id
=
delete_oee_tags
[
"project_id"
])
return_json
=
oee_handlers
.
OeeServices
.
delete_oee_tags
(
project_id
=
delete_oee_tags
[
"project_id"
])
return
return_json
except
Exception
as
e
:
...
...
@@ -41,10 +46,10 @@ async def delete_oee_tagging(delete_oee_tags: GetOeeServices):
@
oee_services
.
post
(
Endpoints
.
oee_services
)
async
def
update_oee_tag
ging
(
update_oee_tags
:
GetOeeServices
):
async
def
update_oee_tag
(
update_oee_tags
:
GetOeeServices
):
try
:
update_oee_tags
=
update_oee_tags
.
dict
()
return_json
=
oee_handlers
.
Oee
_
Services
.
update_oee_tags
(
update_oee_tags
)
return_json
=
oee_handlers
.
OeeServices
.
update_oee_tags
(
update_oee_tags
)
return
return_json
except
Exception
as
e
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment