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
45f6bbe8
Commit
45f6bbe8
authored
May 23, 2022
by
hrishikesh.r
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made Further changes to Oee_handlers.py
parent
071b0650
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
34 deletions
+42
-34
scripts/core/handlers/oee_handlers.py
scripts/core/handlers/oee_handlers.py
+16
-29
scripts/schemas/mongo_schema.py
scripts/schemas/mongo_schema.py
+22
-0
scripts/schemas/oee_config_schema.py
scripts/schemas/oee_config_schema.py
+4
-5
No files found.
scripts/core/handlers/oee_handlers.py
View file @
45f6bbe8
from
scripts.logging
import
logger
from
scripts.utils.mongo_util
import
MongoCollectionBaseClass
from
scripts.schemas.oee_config_schema
import
oee_tag_mapping_list
,
get_oee_tag
,
update_oee_tags
,
project_id
from
scripts.schemas.oee_config_schema
import
Oee_Tag_Mapping_List
,
Get_Oee_Tag
,
Update_Oee_Tags
,
Get_Project_Id
from
scripts.constants
import
CommonKeys
from
scripts.db.mongo.ilens_configuration
import
database
from
scripts.db.mongo.ilens_configuration.collections
import
collection_constants
from
scripts.utils.mongo_util
import
MongoCollectionBaseClass
from
scripts.schemas
import
mongo_schema
from
scripts.constants.db_connections
import
mongo_client
class
Oee_Services
:
def
__init__
(
self
):
def
__init__
(
self
,
project_id
=
Get_Project_Id
.
project_id
):
try
:
self
.
connect
=
MongoCollectionBaseClass
(
mongo_client
=
mongo_client
,
database
=
"ilens_configuration"
,
collection
=
"oee_tag_mapping"
)
self
.
connect
=
collection_constants
(
mongo_client
=
mongo_client
)
except
Exception
as
e
:
logger
.
exception
(
"Error while connecting to mongodb"
)
def
oee_tag_mapping
(
self
,
oee_tag_mapping_list
:
oee_tag_mapping_l
ist
):
def
oee_tag_mapping
(
self
,
oee_tag_mapping_list
:
Oee_Tag_Mapping_L
ist
):
try
:
return_json
=
{
"message"
:
"failure"
,
"status"
:
"failure"
,
"message"
:
"data not inserted in to mongodb"
}
insert_json
=
{
"hierarchy"
:
oee_tag_mapping_list
.
hierarchy
,
"project_id"
:
oee_tag_mapping_list
.
project_id
,
"meta"
:
oee_tag_mapping_list
.
project_id
,
...
...
@@ -24,18 +28,12 @@ class Oee_Services:
result
=
self
.
connect
.
insert_one
(
data
=
insert_json
)
if
result
:
logger
.
info
(
"Data inserted in to mongodb successfully"
)
return_json
[
"message"
]
=
"success"
return_json
[
"status"
]
=
"success"
else
:
logger
.
info
(
"Unable to insert data in to Mongodb"
)
return
return_json
except
Exception
as
e
:
logger
.
exception
(
"Error occurred while inserting data"
)
def
get_oee_tag_mapping
(
self
,
get_oee_tag
:
get_oee_tag
):
def
get_oee_tag_mapping
(
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
}
...
...
@@ -43,10 +41,6 @@ class Oee_Services:
no_of_documents
=
self
.
connect
.
count_documents
(
query
=
query
)
result
=
self
.
connect
.
find
(
query
=
query
)
.
skip
(
skips
)
.
limit
(
get_oee_tag
.
page_num
)
if
result
:
return_json
[
"message"
]
=
"success"
return_json
[
"status"
]
=
"success"
return_json
[
"data"
]
=
result
return_json
[
"total_records"
]
=
no_of_documents
if
skips
<
no_of_documents
:
return_json
[
"endOfrecords"
]
=
False
else
:
...
...
@@ -55,8 +49,7 @@ class Oee_Services:
except
Exception
as
e
:
logger
.
exception
(
f
"Exception occured while fetching data as {e}"
)
def
delete_oee_tags
(
self
,
project_id
:
project_id
):
def
delete_oee_tags
(
self
,
project_id
:
Get_Project_Id
):
try
:
return_json
=
{
"message"
:
"failure"
,
"status"
:
"failure"
,
"data"
:
"data not found"
}
query
=
{
"project_id"
:
project_id
.
project_id
}
...
...
@@ -69,17 +62,11 @@ class Oee_Services:
except
Exception
as
e
:
logger
.
exception
(
f
"Exception occurred while fetching data as {e}"
)
def
update_oee_tags
(
self
,
update_oee_tags
:
update_oee_tags
):
def
update_oee_tags
(
self
,
update_oee_tags
:
Update_Oee_Tags
):
try
:
return_json
=
{
"message"
:
"failure"
,
"status"
:
"failure"
,
"data"
:
"data not found"
}
query
=
{
"project_id"
:
[
'update_oee_tags.projec_id'
]}
result
=
self
.
connect
.
update_one
(
query
=
query
,
data
=
return_json
)
query
=
{
"project_id"
:
[
'update_oee_tags.project_id'
]}
result
=
self
.
connect
.
update_one
(
query
=
query
)
if
result
:
return_json
[
"message"
]
=
"success"
return_json
[
"status"
]
=
"success"
return_json
[
"data"
]
=
result
return
return_json
return
result
except
Exception
as
e
:
logger
.
exception
(
f
"Exception occured while fetching data as {e}"
)
scripts/schemas/mongo_schema.py
0 → 100644
View file @
45f6bbe8
from
pydantic
import
BaseModel
from
typing
import
Any
,
Optional
from
scripts.constants
import
CommonKeys
from
scripts.db.mongo.ilens_configuration
import
database
from
scripts.db.mongo.ilens_configuration.collections
import
collection_constants
from
scripts.utils.mongo_util
import
MongoCollectionBaseClass
class
ConstantsSchema
(
BaseModel
):
type
:
Optional
[
str
]
data
:
Optional
[
Any
]
map_json
:
Optional
[
Any
]
content_type
:
Optional
[
Any
]
content
:
Optional
[
Any
]
class
Constants
(
MongoCollectionBaseClass
):
def
__init__
(
self
,
mongo_client
):
super
()
.
__init__
(
mongo_client
,
database
=
database
,
collection
=
collection_constants
)
scripts/schemas/oee_config_schema.py
View file @
45f6bbe8
from
pydantic
import
BaseModel
class
oee_tag_mapping_l
ist
(
BaseModel
):
class
Oee_Tag_Mapping_L
ist
(
BaseModel
):
hierarchy
:
str
project_id
:
str
meta
:
str
oee_tag_mapping
:
str
class
get_oee_t
ag
(
BaseModel
):
class
Get_Oee_T
ag
(
BaseModel
):
project_id
:
str
page_size
:
str
page_num
:
str
class
project_id
(
BaseModel
):
class
Get_Project_Id
(
BaseModel
):
project_id
:
str
class
update_oee_t
ags
(
BaseModel
):
class
Update_Oee_T
ags
(
BaseModel
):
project_id
:
str
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