Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
app_install
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
tarun.madamanchi
app_install
Commits
f6bb146b
Commit
f6bb146b
authored
Jan 10, 2024
by
tarun2512
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fourth commit
parent
6101e0c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
28 deletions
+29
-28
.env
.env
+3
-3
app_clone_script_copy.py
app_clone_script_copy.py
+26
-25
No files found.
.env
View file @
f6bb146b
MONGO_URI=mongodb://
admin:iLens%23QAv513
@192.168.0.217:30904/?authMechanism=DEFAULT&directConnection=true
MONGO_URI=mongodb://@192.168.0.217:30904/?authMechanism=DEFAULT&directConnection=true
BASE_URI=https://qa.unifytwin.com/
LOGIN_TOKEN=
e4b4059ab01b488abdbc865f8d4cb543
USER_ID=
fpWx7Aw4NJzzXWxcE6w5dU
LOGIN_TOKEN=
dd350397643246daa19ac63c0060d430
USER_ID=
user_099
PROJECT_ID=project_287
APP_NAME=FT Energy Manager
PREFIX=project_287
...
...
app_clone_script_copy.py
View file @
f6bb146b
...
...
@@ -61,7 +61,7 @@ class Connection(Database):
def
get_next_id
(
param
,
prefix
=
None
):
connection
=
Connection
(
prefix
=
prefix
)
next_id_doc
=
connection
.
unique_id
.
find_one
(
query
=
{
"key"
:
param
})
next_id_doc
=
connection
.
unique_id
.
find_one
({
"key"
:
param
})
if
not
next_id_doc
:
insert_dict
=
{
"key"
:
param
,
"id"
:
100
}
connection
.
unique_id
.
insert_one
(
insert_dict
)
...
...
@@ -114,9 +114,9 @@ def push_app_category(folder_path, folder_name, user_details, project_id, prefix
app_category
[
"project_id"
]
=
project_id
app_category
[
'created_at'
]
=
time
.
time
()
app_category
[
'created_by'
]
=
user_details
.
get
(
'user_id'
,
''
)
app_category
[
"app_category_id"
]
=
str
(
get_next_id
(
"app_category"
,
prefix
))
app_category
[
"app_category_id"
]
=
"app_category_"
+
str
(
get_next_id
(
"app_category"
,
prefix
))
query
=
{
"name"
:
app_category
.
get
(
"name"
)}
connection
.
category_apps
.
update_one
(
query
,
app_category
,
upsert
=
True
)
connection
.
category_apps
.
update_one
(
query
,
{
"$set"
:
app_category
}
,
upsert
=
True
)
app_category_mapping
[
old_app_category_id
]
=
app_category
.
get
(
"app_category_id"
)
return
app_category_mapping
...
...
@@ -191,7 +191,7 @@ def process_axis(y_axis, hierarchy_list, parameter_id_mapping, unit_id_mapping,
if
not
tag
:
continue
tag
.
update
(
value
=
f
"{hierarchy.get('id')}${parameter_id_mapping.get(tag.get('value'))}"
)
tag
.
get
(
"unit"
)
.
update
({
"value"
:
unit_id_mapping
.
get
(
tag
.
get
(
"unit"
,
{})
)
.
get
(
"value"
)})
tag
.
get
(
"unit"
)
.
update
({
"value"
:
unit_id_mapping
.
get
(
tag
.
get
(
"unit"
,
{})
.
get
(
"value"
)
)})
else
:
for
axis_val
in
y_axis
:
if
type
(
axis_val
)
!=
dict
or
not
axis_val
.
get
(
"tag"
):
...
...
@@ -204,7 +204,7 @@ def process_axis(y_axis, hierarchy_list, parameter_id_mapping, unit_id_mapping,
if
not
tag
:
continue
tag
.
update
(
value
=
parameter_id_mapping
.
get
(
tag
.
get
(
'value'
)))
tag
.
get
(
"unit"
)
.
update
({
"value"
:
unit_id_mapping
.
get
(
tag
.
get
(
"unit"
,
{})
)
.
get
(
"value"
)})
tag
.
get
(
"unit"
)
.
update
({
"value"
:
unit_id_mapping
.
get
(
tag
.
get
(
"unit"
,
{})
.
get
(
"value"
)
)})
def
manipulate_chart_options_widget
(
hierarchy_list
,
y_axis
,
x_axis
,
filter_parameters
,
widget_type
,
unit_id_mapping
,
parameter_id_mapping
):
...
...
@@ -217,8 +217,10 @@ def manipulate_chart_options_widget(hierarchy_list, y_axis, x_axis, filter_param
def
manipulate_widget_data
(
widget_data
,
project_id
,
hierarchy_list
,
unit_id_mapping
,
parameter_id_mapping
):
widget_data
[
"project_id"
]
=
project_id
if
"filterList"
in
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
][
"filter"
]
and
"filtersData"
in
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
][
"filter"
]:
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
][
"filter"
][
"filterList"
]
=
hierarchy_list
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
][
"filter"
][
"filtersData"
]
=
hierarchy_list
for
filter_data
in
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
][
"filter"
][
"filterList"
]:
filter_data
[
'value'
]
=
hierarchy_list
for
filter_data
in
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
][
"filter"
][
"filtersData"
]:
filter_data
[
'value'
]
=
hierarchy_list
y_axis
=
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
]
.
get
(
"yaxis"
,
" "
)
x_axis
=
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
]
.
get
(
"xaxis"
,
" "
)
filter_parameters
=
widget_data
[
"widget_data"
][
"cData"
][
"chartOptions"
]
.
get
(
"filterParameters"
,
" "
)
...
...
@@ -331,9 +333,9 @@ def push_unit_group(folder_path, folder_name, project_id, prefix=None):
unit_group_mapping
[
old_unit_group_id
]
=
unit_group_data
.
get
(
"id"
)
continue
unit_group
[
"project_id"
]
=
project_id
unit_group
[
"id"
]
=
str
(
get_next_id
(
"group"
,
prefix
))
unit_group
[
"id"
]
=
"group_"
+
str
(
get_next_id
(
"group"
,
prefix
))
query
=
{
"group_name"
:
unit_group
.
get
(
"group_name"
)}
connection
.
units_group
.
update_one
(
query
,
unit_group
,
upsert
=
True
)
connection
.
units_group
.
update_one
(
query
,
{
"$set"
:
unit_group
}
,
upsert
=
True
)
unit_group_mapping
[
old_unit_group_id
]
=
unit_group
.
get
(
"id"
)
return
unit_group_mapping
...
...
@@ -365,10 +367,10 @@ def push_units(folder_path, collection_data, project_id, prefix=None):
unit_id_mapping
[
old_unit_id
]
=
unit_data
.
get
(
"id"
)
continue
unit
[
"project_id"
]
=
project_id
unit
[
"id"
]
=
str
(
get_next_id
(
"unit"
,
prefix
))
unit
[
"id"
]
=
"unit_"
+
str
(
get_next_id
(
"unit"
,
prefix
))
unit
[
'unit_group_id'
]
=
unit_group_mapping
.
get
(
unit
.
get
(
"unit_group_id"
),
unit
.
get
(
"unit_group_id"
))
query
=
{
"name"
:
unit
.
get
(
"name"
)}
connection
.
dashboard_category
.
update_one
(
query
,
{
"$set"
:
unit
},
upsert
=
True
)
connection
.
units
.
update_one
(
query
,
{
"$set"
:
unit
},
upsert
=
True
)
unit_id_mapping
[
old_unit_id
]
=
unit
.
get
(
"id"
)
return
unit_id_mapping
...
...
@@ -397,9 +399,9 @@ def push_tag_category(folder_path, folder_name, prefix=None):
connection
.
tag_category
.
update_one
(
query
,
{
"$set"
:
tag_category_data
},
upsert
=
True
)
tag_category_mapping
[
old_tag_category_id
]
=
tag_category_data
.
get
(
"tag_category_id"
)
continue
tag_category
[
"tag_category_id"
]
=
str
(
get_next_id
(
"tag_category"
,
prefix
))
tag_category
[
"tag_category_id"
]
=
"tag_category_"
+
str
(
get_next_id
(
"tag_category"
,
prefix
))
query
=
{
"tag_category_name"
:
tag_category
.
get
(
"tag_category_name"
)}
connection
.
units_group
.
update_one
(
query
,
tag_category
,
upsert
=
True
)
connection
.
units_group
.
update_one
(
query
,
{
"$set"
:
tag_category
}
,
upsert
=
True
)
tag_category_mapping
[
old_tag_category_id
]
=
tag_category
.
get
(
"tag_category_id"
)
return
tag_category_mapping
...
...
@@ -428,9 +430,9 @@ def push_tag_group(folder_path, folder_name, prefix=None):
connection
.
tag_groups
.
update_one
(
query
,
{
"$set"
:
tag_group_data
},
upsert
=
True
)
tag_group_mapping
[
old_tag_group_id
]
=
tag_group_data
.
get
(
"tag_group_id"
)
continue
tag_group
[
"tag_group_id"
]
=
str
(
get_next_id
(
"tag_group"
,
prefix
))
tag_group
[
"tag_group_id"
]
=
"tag_group_"
+
str
(
get_next_id
(
"tag_group"
,
prefix
))
query
=
{
"tag_group_name"
:
tag_group
.
get
(
"tag_group_name"
)}
connection
.
units_group
.
update_one
(
query
,
tag_group
,
upsert
=
True
)
connection
.
units_group
.
update_one
(
query
,
{
"$set"
:
tag_group
}
,
upsert
=
True
)
tag_group_mapping
[
old_tag_group_id
]
=
tag_group
.
get
(
"tag_group_id"
)
return
tag_group_mapping
...
...
@@ -471,7 +473,7 @@ def push_parameters(folder_path, collection_data, unit_id_mapping, project_id, p
tag
[
"tag_group_id"
]
=
tag_group_mapping
.
get
(
tag
.
get
(
"tag_group_id"
),
""
)
tag
[
"tag_category_id"
]
=
tag_category_mapping
.
get
(
tag
.
get
(
"tag_category_id"
),
""
)
tag
[
'unit'
]
=
unit_id_mapping
.
get
(
tag
.
get
(
"unit"
),
""
)
tag
[
"id"
]
=
tag
[
"tag_id"
]
=
str
(
get_next_id
(
"tag"
,
prefix
))
tag
[
"id"
]
=
tag
[
"tag_id"
]
=
"tag_"
+
str
(
get_next_id
(
"tag"
,
prefix
))
query
=
{
"tag_name"
:
tag
.
get
(
"tag_name"
)}
connection
.
tags
.
update_one
(
query
,
{
"$set"
:
tag
},
upsert
=
True
)
parameter_id_mapping
[
old_tag_id
]
=
tag
.
get
(
"tag_id"
)
...
...
@@ -489,14 +491,14 @@ def push_app(folder_path, collection_data, user_id, user_details, project_id, pr
app_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"customer_apps"
),
f
"{collection_data.get('customer_apps')}.json"
)
app_data
=
CloneScriptHelper
()
.
read_json_file
(
app_file_path
)
category_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"category_apps"
))
new_category_data
=
push_app_category
(
category_file_path
,
collection_data
.
get
(
"category_apps"
),
user_
id
,
project_id
,
prefix
)
new_category_data
=
push_app_category
(
category_file_path
,
collection_data
.
get
(
"category_apps"
),
user_
details
,
project_id
,
prefix
)
dashboard_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"dashboard"
))
push_dashboard
(
dashboard_file_path
,
collection_data
.
get
(
"
category_apps
"
),
user_details
,
project_id
,
prefix
)
push_dashboard
(
dashboard_file_path
,
collection_data
.
get
(
"
dashboard
"
),
user_details
,
project_id
,
prefix
)
category_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"category"
))
push_category
(
category_file_path
,
collection_data
.
get
(
"category"
),
project_id
,
prefix
)
unit_id_mapping
,
parameter_id_mapping
=
get_new_tag_and_unit_ids
(
folder_path
,
collection_data
,
project_id
,
prefix
)
widget_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"widget"
))
push_widget
(
widget_file_path
,
collection_data
.
get
(
"widget
_data
"
),
project_id
,
unit_id_mapping
,
parameter_id_mapping
,
prefix
)
push_widget
(
widget_file_path
,
collection_data
.
get
(
"widget"
),
project_id
,
unit_id_mapping
,
parameter_id_mapping
,
prefix
)
for
data
in
app_data
:
data
[
"access_list"
][
"users"
]
.
append
(
user_id
)
data
[
"project_id"
]
=
project_id
...
...
@@ -506,6 +508,7 @@ def push_app(folder_path, collection_data, user_id, user_details, project_id, pr
data
[
'app_category_id'
]
=
new_category_data
.
get
(
data
.
get
(
'app_category_id'
))
query
=
{
"app_id"
:
data
.
get
(
"app_id"
)}
connection
.
customer_apps
.
update_one
(
query
,
{
"$set"
:
data
},
upsert
=
True
)
print
(
"apps got pushed"
)
def
push_data
(
folder_path
,
collection_data
,
user_id
,
project_id
,
prefix
=
None
):
...
...
@@ -519,13 +522,11 @@ def extract_app_zip(app_name, user_id, project_id, prefix=None):
folder_path
=
os
.
path
.
join
(
BASE_PATH
,
MOUNT_DIR
,
app_name
)
CloneScriptHelper
()
.
unzip_file
(
zip_path
,
folder_path
)
folders_list
=
CloneScriptHelper
()
.
list_folders
(
folder_path
)
folders_list
.
pop
(
"app_image"
)
folders_list
.
pop
(
"app_logo"
)
collection_names
=
[]
folders_list
.
remove
(
"app_image"
)
folders_list
.
remove
(
"app_logo"
)
collection_names
=
{}
for
folder
in
folders_list
:
collection_names
=
{
folder
.
split
(
"."
)[
1
]:
folder
}
collection_names
[
folder
.
split
(
"."
)[
1
]]
=
folder
push_data
(
folder_path
,
collection_names
,
user_id
,
project_id
,
prefix
)
...
...
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