Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
index_info_script
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
index_info_script
Commits
83d4918c
Commit
83d4918c
authored
Apr 24, 2025
by
OWAIZ MUSTAFA KHAN
😎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Script to make excel sheet out of mongo indexes
parent
49e8cd67
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
186 additions
and
1 deletion
+186
-1
Index Data.csv
Index Data.csv
+111
-0
Index Data.xlsx
Index Data.xlsx
+0
-0
index_operations_v2.py
index_operations_v2.py
+2
-1
scripts/schemas/mongo_schema.py
scripts/schemas/mongo_schema.py
+16
-0
to_excel.py
to_excel.py
+57
-0
No files found.
Index Data.csv
0 → 100644
View file @
83d4918c
database,collection,index,type,keys,unique,sparse
ilens_assistant,task_info,1,compound,"(task_info_id, DESC), (project_id, DESC)",FALSE,FALSE
,,2,simple,"(task_info_id, DESC)",FALSE,FALSE
,task_instance_data,1,compound,"(stage_id, ASC), (step_id, ASC), (project_id, ASC)",FALSE,FALSE
,,2,compound,"(stage_id, ASC), ( task_id, ASC)",FALSE,FALSE
,,3,simple,"(stage_id, DESC)",FALSE,FALSE
,workflow_permissions_2024_07_01,1,compound,"(sequence_no, ASC), (step_id, ASC), (user_role, ASC), (workflow_id, ASC), (workflow_status, ASC)",FALSE,FALSE
,periodic_data,1,compound,"(date, DESC), (step_id, ASC)",FALSE,FALSE
,,2,simple,"(step_id, ASC)",FALSE,FALSE
,,3,compound,"(date, DESC), ( step_id, DESC)",FALSE,FALSE
,,4,compound,"(date, ASC), (setp_id, ASC)",FALSE,FALSE
,,5,simple,"(stage_id, DESC)",FALSE,FALSE
,trigger_steps,1,compound,"(date, DESC), (step_id, DESC)",FALSE,FALSE
,,2,compound,"(date, DESC), ( step_id, DESC)",FALSE,FALSE
,workflow_permissions_01-07-2024,1,compound,"(sequence_no, ASC), (step_id, ASC), (user_role, ASC), (workflow_id, ASC), (workflow_status, ASC)",FALSE,FALSE
,,2,compound,"(workflow_id, DESC), ( step_id, DESC), ( user_role, DESC), ( workflow_status, DESC)",FALSE,FALSE
,reference_steps,1,simple,"(step_id, DESC)",FALSE,FALSE
,,2,simple,"(step_id, ASC)",FALSE,FALSE
,,3,simple,"(step_id, ASC)",TRUE,FALSE
,,4,compound,"(step_id, ASC), (task_id, ASC)",FALSE,FALSE
,logbook,1,compound,"(associated_workflow_id, DESC), (logbook_id, DESC), (project_id, DESC)",FALSE,FALSE
,,2,simple,"(logbook_id, ASC)",FALSE,FALSE
,workflows,1,compound,"(workflow_id, DESC), (project_id, DESC)",FALSE,FALSE
,,2,simple,"(workflows_id, ASC)",FALSE,FALSE
,triggers,1,compound,"(workflow_id, DESC), (workflow_version, DESC)",FALSE,FALSE
,,2,compound,"(trigger_id, DESC), ( workflow_id, DESC)",FALSE,FALSE
,steps,1,compound,"(step_id, DESC), (project_id, DESC)",FALSE,FALSE
,,2,compound,"(step_id, DESC), ( step_name, DESC), ( step_category, DESC)",FALSE,FALSE
,,3,simple,"(project_id, ASC)",FALSE,FALSE
,,4,compound,"(step_version, DESC), ( meta.created_at, DESC)",FALSE,FALSE
,,5,simple,"(step_id, ASC)",FALSE,FALSE
,,6,compound,"(project_id, ASC), (step_version, DESC), ( meta.created_at, DESC), (step_id, ASC)",FALSE,FALSE
,task_instances,1,compound,"(task_id, ASC), (logbook_id, ASC)",FALSE,FALSE
,,2,compound,"(task_id, DESC), (task_info_id, DESC)",FALSE,FALSE
,,3,simple,"(step_id, ASC)",FALSE,FALSE
,,4,compound,"(task_category, ASC), (meta.created_at, ASC), (task_description, ASC)",TRUE,FALSE
,form_props,1,simple,"(step_id, DESC)",TRUE,FALSE
,workflow_permissions,1,compound,"(sequence_no, ASC), (step_id, ASC), (user_role, ASC), (workflow_id, ASC), (workflow_status, ASC)",FALSE,FALSE
,,2,compound,"(workflow_id, DESC), ( step_id, DESC), ( user_role, DESC), ( workflow_status, DESC)",FALSE,FALSE
,,3,compound,"(workflow_id, DESC), ( workflow_version, DESC), ( user_role, DESC), (step_id, DESC)",FALSE,FALSE
ilens_configuration,scheduled_jobs,1,simple,"(next_run_time, ASC)",FALSE,TRUE
,site_conf,1,simple,"(site_id, ASC)",FALSE,FALSE
,,2,simple,"(site_id, ASC)",TRUE,FALSE
,tags,1,simple,"(id, ASC)",TRUE,FALSE
,,2,simple,"(tag_id, ASC)",FALSE,FALSE
,job_list,1,simple,"(job_id, DESC)",FALSE,FALSE
,assets,1,simple,"(hierarchy, ASC)",TRUE,FALSE
,,2,simple,"(node_id, ASC)",FALSE,FALSE
,access_group,1,simple,"(access_group_id, ASC)",TRUE,FALSE
,user,1,simple,"(user_id, ASC)",TRUE,FALSE
,user,2,compound,"(user_id, ASC), (project_id, ASC)",FALSE,FALSE
,customer_projects,1,simple,"(customer_project_id, ASC)",TRUE,FALSE
,customer_apps,1,simple,"(app_id, ASC)",TRUE,FALSE
,customer_logos,1,simple,"(project_id, ASC)",TRUE,FALSE
,tag_groups,1,simple,"(id, ASC)",TRUE,FALSE
,units,1,simple,"(id, ASC)",TRUE,FALSE
,materials,1,simple,"(material_id, ASC)",TRUE,FALSE
,tag_category,1,simple,"(tag_category_id, ASC)",TRUE,FALSE
,user_role,1,simple,"(user_role_id, ASC)",TRUE,FALSE
,design_tag_data,1,simple,"(id, ASC)",TRUE,FALSE
,alarm_configuration,1,compound,"(id, DESC), ( project_id, DESC)",FALSE,FALSE
,ext_access_tokens,1,simple,"(expires_in, ASC)",FALSE,FALSE
,accessible_hierarchy,1,compound,"(project_id, ASC), (user_id, ASC)",,
,ilens_devices,1,simple,"(ilens_device_id, ASC)",FALSE,FALSE
,,2,simple,"(physical_device_group_id, ASC)",FALSE,FALSE
,rule_engine,1,compound,"(rule_engine_id, DESC), ( project_id, DESC)",FALSE,FALSE
,,2,simple,"(processOn, ASC)",FALSE,FALSE
,,3,compound,"(rule_engine_id, ASC), ( project_id, ASC)",FALSE,FALSE
,,4,simple,"(last_updated, ASC)",FALSE,FALSE
,tag_hierarchy,1,simple,"(id, ASC)",FALSE,FALSE
,,2,compound,"(project_id, ASC), (id, ASC)",FALSE,FALSE
,,3,simple,"(id, ASC)",TRUE,FALSE
,,4,simple,"(parameter_id, ASC)",FALSE,FALSE
,,5,simple,"(site_id, ASC)",FALSE,FALSE
,,6,simple,"(project_id, ASC)",FALSE,FALSE
,channel_pp_device,1,simple,"(device_model_id, ASC)",FALSE,FALSE
,,2,simple,"(site_id, ASC)",FALSE,FALSE
,,3,simple,"(pipeline_device_id, ASC)",FALSE,FALSE
,data_upload_history,1,compound,"(project_id, DESC), (upload_id, DESC)",FALSE,FALSE
,,2,simple,"(file_id, DESC)",FALSE,FALSE
,rule_template,1,simple,"(rule_template_id, ASC)",FALSE,FALSE
,,2,simple,"(selected_ruleType, ASC)",FALSE,FALSE
,,3,simple,"(category, ASC)",FALSE,FALSE
,hierarchy_details,1,simple,"(node_id, ASC)",FALSE,FALSE
,,2,simple,"(parent_id, ASC)",FALSE,FALSE
,,3,simple,"(type, ASC)",FALSE,FALSE
,,4,simple,"(project_id, ASC)",FALSE,FALSE
,events_collection,1,compound,"(ilens_device_id, DESC), (event_id, DESC)",FALSE,FALSE
,physical_device_group,1,simple,"(physical_device_group_id, ASC)",FALSE,FALSE
,lookup_table,1,compound,"(lookup_name, DESC), (lookup_id, DESC)",FALSE,FALSE
,,2,simple,"(lookup_name, ASC)",FALSE,FALSE
,,3,simple,"(project_id, ASC)",FALSE,FALSE
ilens_widget,widget,1,compound,"(dashboard_id, DESC), (widget_id, DESC)",FALSE,FALSE
,,2,simple,"(widget_id, ASC)",TRUE,FALSE
,ilens_annotations,1,compound,"(hierarchy, ASC), (ts, ASC)",FALSE,FALSE
,dashboard,1,compound,"(dashboard_id, DESC), (lastUpdatedTime, DESC), (project_id, DESC)",FALSE,FALSE
,,2,compound,"(dashboard_id, DESC), (lastUpdatedTime, DESC)",FALSE,FALSE
,,3,simple,"(dashboard_id, ASC)",TRUE,FALSE
,,4,simple,"(category, ASC)",FALSE,FALSE
,category,1,compound,"(dashboard_category_id, DESC), ( project_id, DESC)",FALSE,FALSE
ilens_asset_model,asset_model_rule_engine,1,simple,"(rule_engine_id, ASC)",FALSE,FALSE
,,2,simple,"(project_id, ASC)",FALSE,FALSE
,,3,simple,"(type, ASC)",FALSE,FALSE
,asset_model_details,1,compound,"(asset_model_id, DESC), ( asset_version, DESC)",FALSE,FALSE
,,2,compound,"(asset_model_id, ASC), ( asset_version, ASC)",FALSE,FALSE
,,3,simple,"(asset_model_id, ASC)",FALSE,FALSE
ilens_ebpr,workflow_results,1,simple,"(date_done, ASC)",FALSE,FALSE
ilens_reports,scheduled_jobs_energy_reports,1,simple,"(next_run_time, ASC)",FALSE,TRUE
ilens_schedule_rule,scheduled_jobs,1,simple,"(next_run_time, ASC)",FALSE,TRUE
ilens_events,triggered_alarms,1,compound,"(id, DESC), ( project_id, DESC)",FALSE,FALSE
ilens_hmi,sld_new,1,simple,"(sld_id, ASC)",TRUE,FALSE
Index Data.xlsx
0 → 100644
View file @
83d4918c
File added
index_operations_v2.py
View file @
83d4918c
...
...
@@ -2,7 +2,8 @@
Author: Owaiz Mustafa Khan
Email: owaiz.mustafakhan@rockwellautomation.com
"""
from
dataclasses
import
fields
from
pymongo.errors
import
OperationFailure
...
...
scripts/schemas/mongo_schema.py
View file @
83d4918c
...
...
@@ -73,3 +73,19 @@ class DeleteIndex(BaseModel):
description
=
'The name of database in which metadata collection if present'
,
alias
=
'metadata_db_name'
)
class
AdditionalProperties
(
BaseModel
):
unique
:
bool
=
False
sparse
:
bool
=
False
sort
:
Optional
[
str
]
class
IndexMetadata
(
BaseModel
):
type
:
str
=
'compound'
keys
:
list
[[
str
,
str
]]
|
str
additional_properties
:
AdditionalProperties
class
Export
(
BaseModel
):
database
:
str
collection
:
str
index
:
list
[
IndexMetadata
]
to_excel.py
0 → 100644
View file @
83d4918c
import
pandas
as
pd
from
scripts.utils.mongo_utils
import
get_collection
def
convert_keys_to_excel_standard
(
keys
:
list
):
result
=
''
for
key
in
keys
:
result
+=
f
', ({key[0]}, {key[1]})'
result
=
result
[
2
:]
return
result
def
to_excel
(
collection_name
:
str
,
database_name
:
str
):
collection
=
get_collection
(
collection_name
,
database_name
)
collections_info
=
collection
.
find
({},
{
'_id'
:
0
})
dic
=
dict
()
collections
=
list
()
data
=
list
()
headers
=
[
'database'
,
'collection'
,
'index'
,
'type'
,
'keys'
,
'unique'
,
'sparse'
]
data
.
append
(
headers
)
for
collection_info
in
collections_info
:
collection_name
=
collection_info
.
get
(
'collection'
)
database_name
=
collection_info
.
get
(
'database'
)
indexes
=
collection_info
.
get
(
'index'
)
collections
.
append
(
collection_name
)
for
index
,
i
in
zip
(
indexes
,
range
(
1
,
len
(
indexes
)
+
1
)):
ap
=
index
.
get
(
'additional_properties'
,
dict
())
if
index
.
get
(
'type'
)
==
'simple'
:
data
.
append
([
database_name
,
collection_name
,
i
,
index
.
get
(
'type'
),
f
"({index.get('keys')}, {ap.get('sort')})"
,
ap
.
get
(
'unique'
,
False
),
ap
.
get
(
'sparse'
,
False
)
])
else
:
data
.
append
([
database_name
,
collection_name
,
i
,
index
.
get
(
'type'
),
convert_keys_to_excel_standard
(
index
.
get
(
'keys'
)),
ap
.
get
(
'unique'
),
ap
.
get
(
'sparse'
)
])
df
=
pd
.
DataFrame
(
data
)
df
.
to_csv
(
'Index Data.csv'
)
to_excel
(
'index_info_v2'
,
'ilens_default_info'
)
\ No newline at end of file
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