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
0ec5489a
Commit
0ec5489a
authored
Jan 24, 2024
by
tarun2512
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fourth commit
parent
0b1ce30f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
app_clone_script_new.py
app_clone_script_new.py
+33
-0
No files found.
app_clone_script_new.py
View file @
0ec5489a
...
@@ -75,6 +75,38 @@ def push_category(folder_path, folder_name, project_id, prefix=None):
...
@@ -75,6 +75,38 @@ def push_category(folder_path, folder_name, project_id, prefix=None):
connection
.
dashboard_category
.
update_one
(
query
,
{
"$set"
:
data
},
upsert
=
True
)
connection
.
dashboard_category
.
update_one
(
query
,
{
"$set"
:
data
},
upsert
=
True
)
def
push_rule_target
(
folder_path
,
folder_name
,
user_details
,
project_id
,
prefix
=
None
):
connection
=
Connection
(
prefix
=
prefix
)
file_path
=
os
.
path
.
join
(
folder_path
,
f
"{folder_name}.json"
)
rule_target_data
=
CloneScriptHelper
()
.
read_json_file
(
file_path
)
zip_rule_target_data
=
{}
for
rule_target
in
rule_target_data
:
zip_rule_target_data
[
rule_target
.
get
(
"data"
)
.
get
(
'target_name'
)]
=
rule_target
.
get
(
'rule_target_id'
)
existed_rule_target_data
=
list
(
connection
.
category_apps
.
find
(
{
"data.target_name"
:
{
"$in"
:
list
(
zip_rule_target_data
.
keys
())},
"project_id"
:
project_id
},
{
"_id"
:
0
}
)
)
existed_app_category_mapping_data
=
{}
for
existed_app_category
in
existed_rule_target_data
:
existed_app_category_mapping_data
[
existed_app_category
.
get
(
'name'
)]
=
existed_app_category
for
rule_target
in
rule_target_data
:
if
rule_target
.
get
(
'data'
)
.
get
(
"target_name"
)
in
existed_app_category_mapping_data
:
app_category_data
=
existed_app_category_mapping_data
.
get
(
rule_target
.
get
(
'data'
)
.
get
(
"target_name"
))
app_category_data
[
"project_id"
]
=
project_id
app_category_data
[
'created_on'
]
=
time
.
time
()
app_category_data
[
'created_by'
]
=
user_details
.
get
(
'user_id'
,
''
)
query
=
{
"rule_target_id"
:
app_category_data
.
get
(
"rule_target_id"
)}
connection
.
category_apps
.
update_one
(
query
,
{
"$set"
:
app_category_data
},
upsert
=
True
)
continue
rule_target
[
"project_id"
]
=
project_id
rule_target
[
'created_at'
]
=
time
.
time
()
rule_target
[
'created_by'
]
=
user_details
.
get
(
'user_id'
,
''
)
rule_target
[
"rule_target_id"
]
=
"rule_target_"
+
str
(
get_next_id
(
"rule_target"
,
prefix
))
query
=
{
"data.target_name"
:
rule_target
.
get
(
'data'
)
.
get
(
"target_name"
)}
connection
.
category_apps
.
update_one
(
query
,
{
"$set"
:
rule_target
},
upsert
=
True
)
def
push_app_category
(
folder_path
,
folder_name
,
user_details
,
project_id
,
prefix
=
None
):
def
push_app_category
(
folder_path
,
folder_name
,
user_details
,
project_id
,
prefix
=
None
):
connection
=
Connection
(
prefix
=
prefix
)
connection
=
Connection
(
prefix
=
prefix
)
file_path
=
os
.
path
.
join
(
folder_path
,
f
"{folder_name}.json"
)
file_path
=
os
.
path
.
join
(
folder_path
,
f
"{folder_name}.json"
)
...
@@ -260,6 +292,7 @@ def push_app(folder_path, collection_data, user_id, user_details, project_id, pr
...
@@ -260,6 +292,7 @@ def push_app(folder_path, collection_data, user_id, user_details, project_id, pr
app_data
=
CloneScriptHelper
()
.
read_json_file
(
app_file_path
)
app_data
=
CloneScriptHelper
()
.
read_json_file
(
app_file_path
)
category_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"category_apps"
))
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_details
,
project_id
,
prefix
)
new_category_data
=
push_app_category
(
category_file_path
,
collection_data
.
get
(
"category_apps"
),
user_details
,
project_id
,
prefix
)
push_rule_target
(
category_file_path
,
collection_data
.
get
(
"rule_targets"
),
user_details
,
project_id
,
prefix
)
dashboard_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"dashboard"
))
dashboard_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"dashboard"
))
push_dashboard
(
dashboard_file_path
,
collection_data
.
get
(
"dashboard"
),
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"
))
category_file_path
=
os
.
path
.
join
(
folder_path
,
collection_data
.
get
(
"category"
))
...
...
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