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
c86b57d7
Commit
c86b57d7
authored
Jun 01, 2022
by
shreya.m
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added customer project function query
parent
49bd76d4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
265 additions
and
146 deletions
+265
-146
scripts/config/__init__.py
scripts/config/__init__.py
+6
-0
scripts/constants/app_constants.py
scripts/constants/app_constants.py
+147
-143
scripts/core/handlers/oee_handlers.py
scripts/core/handlers/oee_handlers.py
+10
-1
scripts/db/mongo/ilens_configuration/collections/customer_projects.py
...ongo/ilens_configuration/collections/customer_projects.py
+87
-0
scripts/db/mongo/schema/tag_hierarchy.py
scripts/db/mongo/schema/tag_hierarchy.py
+14
-1
scripts/db/redis_connections.py
scripts/db/redis_connections.py
+1
-1
No files found.
scripts/config/__init__.py
View file @
c86b57d7
...
...
@@ -43,6 +43,12 @@ class Service:
secure_cookie
=
config
.
get
(
"SERVICE"
,
"secure_cookie"
)
class
DatabaseConstants
:
metadata_db
=
config
.
get
(
"DATABASES"
,
"metadata_db"
)
if
not
bool
(
metadata_db
):
metadata_db
=
"ilens_configuration"
class
DBConf
:
POSTGRES_URI
=
config
.
get
(
'POSTGRES'
,
'uri'
)
if
not
POSTGRES_URI
:
...
...
scripts/constants/app_constants.py
View file @
c86b57d7
class
DatabaseNames
:
ilens_assistant
=
"ilens_assistant"
from
scripts.config
import
DatabaseConstants
class
DatabaseNames
:
ilens_assistant
=
"ilens_assistant"
ilens_configuration
=
DatabaseConstants
.
metadata_db
class
CollectionNames
:
oee_tags
=
"oeetags"
customer_projects
=
"customer_projects"
class
TableContent
:
FETCH_STEP_HEADER_CONTENT
=
[
{
"value"
:
"step_name"
,
"label"
:
"Step Name"
,
"enableClick"
:
True
,
"style"
:
"indicate-item cursor-pointer"
,
"action"
:
{
"action"
:
"edit"
,
"label"
:
"Edit"
,
"type"
:
"edit"
}
},
{
"value"
:
"description"
,
"label"
:
"Description"
}
]
fetch_step_table_actions
=
{
"actions"
:
[
{
"action"
:
"edit"
,
"label"
:
"Edit"
,
"type"
:
"edit"
,
"icon-class"
:
"fa fa-pencil"
},
{
"action"
:
"delete"
,
"label"
:
"Delete"
,
"type"
:
"delete"
,
"icon-class"
:
"fa fa-trash"
}
],
"enableActions"
:
True
,
"externalActions"
:
[
{
"action"
:
"addnew"
,
"label"
:
"Create New"
,
"type"
:
"addnew"
}
]
}
class
StatusResponses
:
PLANNED
=
"PLANNED"
ALL
=
"ALL"
PENDING
=
"PENDING"
COMPLETED
=
"COMPLETED"
PENDING_FOR_REVIEW
=
"PENDING_FOR_REVIEW"
PENDING_FOR_APPROVAL
=
"PENDING_FOR_APPROVAL"
IN_PROGRESS
=
"IN_PROGRESS"
REVIEW_REJECTED
=
"REVIEW_REJECTED"
APPROVAL_REJECTED
=
"APPROVAL_REJECTED"
APPROVED
=
"APPROVED"
IS_STARTED
=
"is_started"
IS_TASK_COMPLETED
=
"is_task_completed"
IS_PAUSED
=
"is_paused"
CLOSED
=
"CLOSED"
RESOLVED
=
"RESOLVED"
class
UserRoleCollectionKeys
:
KEY_USER_ROLE_ID
=
"user_role_id"
KEY_PROJECT_ID
=
"project_id"
class
SiteConfCollectionKeys
:
KEY_SITE_NAME
=
"site_name"
KEY_SITE_INFO
=
"site_info"
KEY_CUSTOMER_PROJECT_ID
=
"customer_project_id"
KEY_SITE_ID
=
"site_id"
KEY_PRODUCT_ENCRYPTED
=
"product_encrypted"
KEY_PROCESS_ID
=
"process_id"
class
CustomerProjectKeys
:
KEY_CUSTOMER_PROJECT_ID
=
"customer_project_id"
KEY_CUSTOMER_PROJECT_NAME
=
"customer_project_name"
KEY_SITE_TEMPLT_ID
=
"site_templt_id"
KEY_PROCESS_TEMPLT_ID
=
"process_templt_id"
class
DBConsts
:
kairos_std_metric_name
=
'ilens.live_data.raw'
kairos_column_names
=
[
"timestamp"
,
"value"
]
kairos_time_unit
=
"ms"
kairos_version_api
=
"/api/v1/version"
kairos_health_check
=
"/api/v1/health/status"
kairos_query_api
=
"/api/v1/datapoints/query"
kairos_write_data_api
=
"/api/v1/datapoints"
class
Secrets
:
LOCK_OUT_TIME_MINS
=
30
leeway_in_mins
=
10
unique_key
=
'45c37939-0f75'
token
=
'8674cd1d-2578-4a62-8ab7-d3ee5f9a'
issuer
=
"ilens"
alg
=
"RS256"
class
StepCategories
:
NON_PERIODIC
=
"step_category_100"
TASK_CREATION
=
"step_category_101"
PERIODIC
=
"step_category_102"
TRIGGER_BASED
=
"step_category_103"
class
CommonStatusCode
:
SUCCESS_CODES
=
(
200
,
201
,
204
,
)
class
EmailAuth
:
username
=
'AllGoodNamesRGone'
password
=
'comBRANSeANtamasEbICaPeC'
# class TableContent:
# FETCH_STEP_HEADER_CONTENT = [
# {
# "value": "step_name",
# "label": "Step Name",
# "enableClick": True,
# "style": "indicate-item cursor-pointer",
# "action": {"action": "edit", "label": "Edit", "type": "edit"}
# },
# {
# "value": "description",
# "label": "Description"
# }
# ]
# fetch_step_table_actions = {
# "actions": [
# {
# "action": "edit",
# "label": "Edit",
# "type": "edit",
# "icon-class": "fa fa-pencil"
# },
# {
# "action": "delete",
# "label": "Delete",
# "type": "delete",
# "icon-class": "fa fa-trash"
# }
# ],
# "enableActions": True,
# "externalActions": [
# {
# "action": "addnew",
# "label": "Create New",
# "type": "addnew"
# }
# ]
# }
#
#
# class StatusResponses:
# PLANNED = "PLANNED"
# ALL = "ALL"
# PENDING = "PENDING"
# COMPLETED = "COMPLETED"
# PENDING_FOR_REVIEW = "PENDING_FOR_REVIEW"
# PENDING_FOR_APPROVAL = "PENDING_FOR_APPROVAL"
# IN_PROGRESS = "IN_PROGRESS"
# REVIEW_REJECTED = "REVIEW_REJECTED"
# APPROVAL_REJECTED = "APPROVAL_REJECTED"
# APPROVED = "APPROVED"
# IS_STARTED = "is_started"
# IS_TASK_COMPLETED = "is_task_completed"
# IS_PAUSED = "is_paused"
# CLOSED = "CLOSED"
# RESOLVED = "RESOLVED"
#
#
# class UserRoleCollectionKeys:
# KEY_USER_ROLE_ID = "user_role_id"
# KEY_PROJECT_ID = "project_id"
#
#
# class SiteConfCollectionKeys:
# KEY_SITE_NAME = "site_name"
# KEY_SITE_INFO = "site_info"
# KEY_CUSTOMER_PROJECT_ID = "customer_project_id"
# KEY_SITE_ID = "site_id"
# KEY_PRODUCT_ENCRYPTED = "product_encrypted"
# KEY_PROCESS_ID = "process_id"
#
#
# class CustomerProjectKeys:
# KEY_CUSTOMER_PROJECT_ID = "customer_project_id"
# KEY_CUSTOMER_PROJECT_NAME = "customer_project_name"
# KEY_SITE_TEMPLT_ID = "site_templt_id"
# KEY_PROCESS_TEMPLT_ID = "process_templt_id"
#
#
# class DBConsts:
# kairos_std_metric_name = 'ilens.live_data.raw'
# kairos_column_names = ["timestamp", "value"]
# kairos_time_unit = "ms"
# kairos_version_api = "/api/v1/version"
# kairos_health_check = "/api/v1/health/status"
# kairos_query_api = "/api/v1/datapoints/query"
# kairos_write_data_api = "/api/v1/datapoints"
#
#
# class Secrets:
# LOCK_OUT_TIME_MINS = 30
# leeway_in_mins = 10
# unique_key = '45c37939-0f75'
# token = '8674cd1d-2578-4a62-8ab7-d3ee5f9a'
# issuer = "ilens"
# alg = "RS256"
#
#
# class StepCategories:
# NON_PERIODIC = "step_category_100"
# TASK_CREATION = "step_category_101"
# PERIODIC = "step_category_102"
# TRIGGER_BASED = "step_category_103"
#
#
# class CommonStatusCode:
# SUCCESS_CODES = (
# 200,
# 201,
# 204,
# )
#
#
# class EmailAuth:
# username = 'AllGoodNamesRGone'
# password = 'comBRANSeANtamasEbICaPeC'
#
#
# class JsonFormats:
# missed_task_format = {
# "className": "scheduledTask",
# "end": "NA",
# "id": "",
# "start": "",
# "title": "",
# "textColor": "#000000",
# "backgroundColor": "",
# "data": {
# "future_task": True,
# "id": "",
# "info": {
# "Logbook Name": "",
# "Hierarchy": "",
# "Created By": ""
# },
# "critical": False,
# "task_category": "",
# "bgColor": "",
# "created_at": ""
# }
# }
class
JsonFormats
:
missed_task_format
=
{
"className"
:
"scheduledTask"
,
"end"
:
"NA"
,
"id"
:
""
,
"start"
:
""
,
"title"
:
""
,
"textColor"
:
"#000000"
,
"backgroundColor"
:
""
,
"data"
:
{
"future_task"
:
True
,
"id"
:
""
,
"info"
:
{
"Logbook Name"
:
""
,
"Hierarchy"
:
""
,
"Created By"
:
""
},
"critical"
:
False
,
"task_category"
:
""
,
"bgColor"
:
""
,
"created_at"
:
""
}
}
scripts/core/handlers/oee_handlers.py
View file @
c86b57d7
import
traceback
from
scripts.db.mongo.ilens_assistant.collection.tag_instance_data
import
TagInstanceData
from
scripts.db.mongo.ilens_configuration.collections.customer_projects
import
CustomerProjects
from
scripts.schemas.batch_oee
import
GetOeeServices
from
scripts.constants.db_connections
import
mongo_client
from
scripts.db.mongo.ilens_configuration.collections
import
collection_constants
...
...
@@ -23,6 +24,7 @@ class OeeServices:
try
:
self
.
tag_data_conn
=
TagInstanceData
(
mongo_client
=
mongo_client
)
self
.
common_utils
=
CommonUtils
()
self
.
customer_project
=
CustomerProjects
(
mongo_client
=
mongo_client
)
# self.hierarchy = TagInstanceData(mongo_client=mongo_client, project_id=project_id)
except
Exception
as
e
:
raise
logger
.
exception
(
f
"Error while connecting to mongodb {e.args}"
)
...
...
@@ -37,7 +39,7 @@ class OeeServices:
if
bool
(
request_data
.
hierarchy
):
insert_json
.
update
(
hierarchy
=
request_data
.
hierarchy
)
result
=
self
.
tag_data_conn
.
add_tag
(
insert_json
)
result
.
meta
.
update
(
self
.
common_utils
.
get_user_meta
(
user_id
,
check_flag
=
True
))
result
.
meta
.
update
(
self
.
common_utils
.
get_user_meta
(
user_id
,
check_flag
=
True
))
if
result
:
return
result
except
Exception
as
e
:
...
...
@@ -74,6 +76,13 @@ class OeeServices:
except
Exception
as
e
:
raise
logger
.
exception
(
f
"Exception occurred while fetching data as {e.args}"
)
def
customer_project
(
self
,
customer_project_id
):
custom_details
=
self
.
customer_project
.
key_customer_project_id
(
customer_project_id
)
for
each
in
custom_details
:
response_data
=
dict
({
"key"
:
each
.
get
(
"customer_project_id"
),
"value"
:
each
.
get
(
"time_zone"
)})
return
response_data
# query = {'project_id': request_data.project_id}
# skips = request_data.page_size * (request_data.page_num - 1)
# no_of_documents = self.tag_data_conn.count_documents(query=query)
...
...
scripts/db/mongo/ilens_configuration/collections/customer_projects.py
0 → 100644
View file @
c86b57d7
from
typing
import
Optional
,
Dict
from
scripts.constants.app_constants
import
CustomerProjectKeys
from
scripts.constants.app_constants
import
DatabaseNames
,
CollectionNames
from
scripts.db.mongo.schema
import
MongoBaseSchema
from
scripts.utils.mongo_util
import
MongoCollectionBaseClass
class
CustomerProjectsSchema
(
MongoBaseSchema
):
"""
This is the Schema for the Mongo DB Collection.
All datastore and general responses will be following the schema.
"""
customer_project_name
:
Optional
[
str
]
description
:
Optional
[
str
]
site_templt_id
:
Optional
[
str
]
logo_name
:
Optional
[
str
]
logo_url
:
Optional
[
str
]
process_templt_id
:
Optional
[
str
]
update_details
:
Optional
[
dict
]
user_id
:
Optional
[
str
]
customer_project_id
:
Optional
[
str
]
product_encrypted
:
Optional
[
bool
]
timezone
:
Optional
[
str
]
=
"Asia/Kolkata"
class
CustomerProjects
(
MongoCollectionBaseClass
):
def
__init__
(
self
,
mongo_client
):
super
()
.
__init__
(
mongo_client
,
database
=
DatabaseNames
.
ilens_configuration
,
collection
=
CollectionNames
.
customer_projects
)
@
property
def
key_customer_project_id
(
self
):
return
CustomerProjectKeys
.
KEY_CUSTOMER_PROJECT_ID
@
property
def
key_customer_project_name
(
self
):
return
CustomerProjectKeys
.
KEY_CUSTOMER_PROJECT_NAME
def
find_project
(
self
,
project_id
=
None
,
project_name
=
None
,
filter_dict
=
None
):
"""
The following function will give one record for a given set of
search parameters as keyword arguments
:param filter_dict:
:param project_id:
:param project_name
:return:
"""
query
=
dict
()
if
project_id
:
query
.
update
({
self
.
key_customer_project_id
:
project_id
})
if
project_name
:
query
.
update
({
self
.
key_customer_project_name
:
project_name
})
record
=
self
.
find_one
(
query
=
query
,
filter_dict
=
filter_dict
)
if
not
record
:
return
dict
()
return
CustomerProjectsSchema
(
**
record
)
.
dict
()
def
find_project_by_query
(
self
,
query
,
filter_dict
=
None
):
record
=
self
.
find
(
query
=
query
,
filter_dict
=
filter_dict
)
if
record
:
return
record
return
list
()
def
insert_one_project
(
self
,
data
):
"""
The following function will insert one project in the
customer_projects collections
:param self:
:param data:
:return:
"""
return
self
.
insert_one
(
data
)
def
update_one_project
(
self
,
project_id
,
data
):
query
=
{
self
.
key_customer_project_id
:
project_id
}
return
self
.
update_one
(
query
=
query
,
data
=
data
)
def
delete_one_project
(
self
,
project_id
):
if
project_id
:
query
=
{
self
.
key_customer_project_id
:
project_id
}
return
self
.
delete_one
(
query
)
else
:
return
False
def
get_project_data_by_aggregate
(
self
,
query
:
list
):
return
list
(
self
.
aggregate
(
pipelines
=
query
))
scripts/db/mongo/schema/tag_hierarchy.py
View file @
c86b57d7
from
pydantic
import
BaseModel
from
typing
import
Optional
class
GetTagsLists
(
BaseModel
):
project_id
:
str
hierarchy
:
str
class
CustomerProjectSchema
(
BaseModel
):
customer_project_name
:
Optional
[
str
]
description
:
Optional
[
str
]
site_templt_id
:
Optional
[
str
]
logo_name
:
Optional
[
str
]
logo_url
:
Optional
[
str
]
process_templt_id
:
Optional
[
str
]
update_details
:
Optional
[
dict
]
user_id
:
Optional
[
str
]
customer_project_id
:
Optional
[
str
]
product_encrypted
:
Optional
[
bool
]
timezone
:
Optional
[
str
]
=
"Asia/Kolkata"
\ No newline at end of file
scripts/db/redis_connections.py
View file @
c86b57d7
...
...
@@ -12,4 +12,4 @@ oee_production_db = redis.from_url(RedisConfig.REDIS_URI, db=int(RedisConfig.OEE
live_tags_db
=
redis
.
from_url
(
RedisConfig
.
REDIS_URI
,
db
=
int
(
RedisConfig
.
LIVE_TAGS_DB
),
decode_responses
=
True
)
partition_db
=
redis
.
from_url
(
RedisConfig
.
REDIS_URI
,
db
=
int
(
KafkaConf
.
redis_db
),
decode_responses
=
True
)
\ No newline at end of file
partition_db
=
redis
.
from_url
(
RedisConfig
.
REDIS_URI
,
db
=
int
(
KafkaConf
.
redis_db
),
decode_responses
=
True
)
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