Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
support_lens
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
support_lens
Commits
93b0c18b
Commit
93b0c18b
authored
Jan 05, 2021
by
harshavardhan.c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new services for support lens dashboard
parent
1c975cab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
367 additions
and
65 deletions
+367
-65
scripts/config/app_constants.py
scripts/config/app_constants.py
+128
-13
scripts/core/handler/resolver_setup_handler.py
scripts/core/handler/resolver_setup_handler.py
+2
-2
scripts/core/handler/supportcase_setup_handler.py
scripts/core/handler/supportcase_setup_handler.py
+195
-44
scripts/core/services/supportcase_setup_configuration.py
scripts/core/services/supportcase_setup_configuration.py
+42
-6
No files found.
scripts/config/app_constants.py
View file @
93b0c18b
...
@@ -16,9 +16,12 @@ class Endpoints:
...
@@ -16,9 +16,12 @@ class Endpoints:
save_support_case
=
base_url
+
"/support_case/create"
save_support_case
=
base_url
+
"/support_case/create"
fetch_support_case
=
base_url
+
"/support_case/fetch"
fetch_support_case
=
base_url
+
"/support_case/fetch"
delete_support_case
=
base_url
+
"/support_case/delete"
delete_case_details
=
base_url
+
"/support_case/delete"
resolve_case_details
=
base_url
+
"/support_case/resolve"
close_case_details
=
base_url
+
"/support_case/close"
edit_support_case
=
base_url
+
"/support_case/edit"
edit_support_case
=
base_url
+
"/support_case/edit"
get_support_case_table_details
=
base_url
+
"/support_case/fetch_table"
get_support_case_table_details
=
base_url
+
"/support_case/fetch_table"
get_dashboard_details
=
base_url
+
"/support_case/get_dashboard_details"
class
DBMapping
:
class
DBMapping
:
...
@@ -39,7 +42,12 @@ class DBMapping:
...
@@ -39,7 +42,12 @@ class DBMapping:
class
CaseStatus
:
class
CaseStatus
:
OPEN
=
"open"
OPEN
=
"open"
DELETE
=
"delete"
DELETED
=
"deleted"
CLOSED
=
"closed"
REPLIED
=
"replied"
RESOLVED
=
"resolved"
RE_ASSIGNED
=
"re_assigned"
ASSIGNED
=
"assigned"
class
StatusMessages
:
class
StatusMessages
:
...
@@ -58,6 +66,8 @@ class StatusMessages:
...
@@ -58,6 +66,8 @@ class StatusMessages:
SUPPORTCASE_SAVE
=
"Failed to save support case details"
SUPPORTCASE_SAVE
=
"Failed to save support case details"
SUPPORTCASE_FETCH
=
"Failed to fetch support case details"
SUPPORTCASE_FETCH
=
"Failed to fetch support case details"
SUPPORTCASE_DASHBOARD
=
"Failed to fetch dashboard details"
SUPPORTCASE
=
"Failed to update case details"
class
StaticJsons
:
class
StaticJsons
:
...
@@ -95,8 +105,8 @@ class StaticJsons:
...
@@ -95,8 +105,8 @@ class StaticJsons:
]
]
SUPPORTLENS_FETCHTABLE_HEADERCONTENT
=
[
SUPPORTLENS_FETCHTABLE_HEADERCONTENT
=
[
{
{
"value"
:
"case_
number
"
,
"value"
:
"case_
id
"
,
"label"
:
"
c
ase Number"
,
"label"
:
"
C
ase Number"
,
"enable_column_search"
:
True
,
"enable_column_search"
:
True
,
"header_type"
:
"text"
"header_type"
:
"text"
},
},
...
@@ -107,18 +117,19 @@ class StaticJsons:
...
@@ -107,18 +117,19 @@ class StaticJsons:
"header_type"
:
"text"
"header_type"
:
"text"
},
},
{
{
"value"
:
"
customer_project_id
"
,
"value"
:
"
ProjectName
"
,
"label"
:
"Customer Project ID"
,
"label"
:
"Customer Project ID"
,
"enable_column_search"
:
True
,
"enable_column_search"
:
True
,
"header_type"
:
"text"
"header_type"
:
"text"
},
},
{
# {
"value"
:
"status"
,
# "value": "status",
"label"
:
"Status"
,
# "label": "Status",
"enable_column_search"
:
True
,
# "enable_column_search": True,
"header_type"
:
"select"
,
# "header_type": "select",
"options"
:
[]
# "options": [],
},
# "hidden": True
# },
{
{
"value"
:
"created_by"
,
"value"
:
"created_by"
,
"label"
:
"Created By"
,
"label"
:
"Created By"
,
...
@@ -127,7 +138,7 @@ class StaticJsons:
...
@@ -127,7 +138,7 @@ class StaticJsons:
"options"
:
[]
"options"
:
[]
},
},
{
{
"value"
:
"last_updated"
,
"value"
:
"last_updated
_on
"
,
"label"
:
"Last Updated"
,
"label"
:
"Last Updated"
,
"enable_column_search"
:
True
,
"enable_column_search"
:
True
,
"header_type"
:
"date_range"
"header_type"
:
"date_range"
...
@@ -159,6 +170,110 @@ class StaticJsons:
...
@@ -159,6 +170,110 @@ class StaticJsons:
]
]
}
}
SUPPORTLENS_HEADER_CONTENT
=
{
"support_lens_table_header_content"
:
[
{
"key"
:
"open"
,
"label"
:
"Open"
,
"svgName"
:
'open.svg'
,
"count"
:
0
,
"className"
:
"w-20"
,
},
{
"key"
:
"replied"
,
"label"
:
"Replied"
,
"count"
:
0
,
"svgName"
:
'replied-yet-to-assign.svg'
,
"className"
:
"w-20"
,
},
{
"key"
:
"assigned"
,
"label"
:
"Assigned"
,
"count"
:
0
,
"svgName"
:
'assigned.svg'
,
"className"
:
"w-20"
,
},
{
"key"
:
"re_assigned"
,
"label"
:
"Re-Assigned"
,
"count"
:
0
,
"svgName"
:
're-assigned.svg'
,
"className"
:
"w-20"
,
},
{
"key"
:
"resolved"
,
"label"
:
"Resolved"
,
"count"
:
0
,
"svgName"
:
'resolved.svg'
,
"className"
:
"w-20"
,
},
{
"key"
:
"deleted"
,
"label"
:
"Deleted"
,
"count"
:
0
,
"svgName"
:
'deleted.svg'
,
"className"
:
"w-20 mr-1"
,
},
{
"key"
:
"closed"
,
"label"
:
"Closed"
,
"count"
:
0
,
"svgName"
:
'closed.svg'
,
"className"
:
"w-20 mr-1"
,
}
],
"support_lens_dashboard_header_content"
:
[
{
"key"
:
"open"
,
"label"
:
"OPEN CASES"
,
"count"
:
0
,
"valueColor"
:
"#484848"
,
"iconStyle"
:
{
"color"
:
'#F44336'
},
"svgName"
:
'open.svg'
},
{
"key"
:
"replied"
,
"label"
:
"REPLIED/ YET TO ASSIGN"
,
"count"
:
0
,
"valueColor"
:
"#484848"
,
"iconStyle"
:
{
'color'
:
'#FFC107'
},
"svgName"
:
'replied-yet-to-assign.svg'
},
{
"key"
:
"assigned"
,
"label"
:
"ASSIGNED CASES"
,
"count"
:
0
,
"valueColor"
:
"#484848"
,
"iconStyle"
:
{
'color'
:
'#03A9F4'
},
"svgName"
:
'assigned.svg'
},
{
"key"
:
"re_assigned"
,
"label"
:
"RE-ASSIGNED CASES"
,
"count"
:
0
,
"valueColor"
:
"#484848"
,
"iconStyle"
:
{
'color'
:
'#3F51B5'
},
"svgName"
:
're-assigned.svg'
},
{
"key"
:
"resolved"
,
"label"
:
"RESOLVED CASES"
,
"count"
:
0
,
"valueColor"
:
"#484848"
,
"iconStyle"
:
{
'color'
:
'#4CAF50'
},
"svgName"
:
'resolved.svg'
}
],
"support_lens_chart_header_content"
:
[
{
"count"
:
0
,
"name"
:
'OPEN CASES'
,
"itemStyle"
:
{
"color"
:
'#EF5350'
},
"key"
:
"open"
},
{
"count"
:
0
,
"name"
:
'REPLIED/ YET TO ASSIGN'
,
"itemStyle"
:
{
"color"
:
'#FFCA28'
},
"key"
:
"replied"
},
{
"count"
:
0
,
"name"
:
'ASSIGNED CASES'
,
"itemStyle"
:
{
"color"
:
'#29B6F6'
},
"key"
:
"assigned"
},
{
"count"
:
0
,
"name"
:
'RE-ASSIGNED CASES'
,
"itemStyle"
:
{
"color"
:
'#5C6BC0'
},
"key"
:
"re_assigned"
},
{
"count"
:
0
,
"name"
:
'RESOLVED CASES'
,
"itemStyle"
:
{
"color"
:
'#66BB6A'
},
"key"
:
"resolved"
},
]
}
class
MongoEncryptionConstants
:
class
MongoEncryptionConstants
:
...
...
scripts/core/handler/resolver_setup_handler.py
View file @
93b0c18b
...
@@ -118,7 +118,7 @@ class ResolverSetupHandler:
...
@@ -118,7 +118,7 @@ class ResolverSetupHandler:
collection_name
=
DBMapping
.
resolver_configuration
,
collection_name
=
DBMapping
.
resolver_configuration
,
set_json
=
record
,
query
=
query_json
)
set_json
=
record
,
query
=
query_json
)
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
"
Category
saved Successfully"
)
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
"
Resolver data
saved Successfully"
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
debug
(
"Exception occurred while saving category data"
+
str
(
e
))
logger
.
debug
(
"Exception occurred while saving category data"
+
str
(
e
))
return
final_json
return
final_json
...
@@ -165,7 +165,7 @@ class ResolverSetupHandler:
...
@@ -165,7 +165,7 @@ class ResolverSetupHandler:
self
.
mongo_obj
.
delete_one_record
(
db_name
=
DBMapping
.
support_lens_configuration
,
self
.
mongo_obj
.
delete_one_record
(
db_name
=
DBMapping
.
support_lens_configuration
,
collection_name
=
DBMapping
.
resolver_configuration
,
collection_name
=
DBMapping
.
resolver_configuration
,
query_json
=
query_json
)
query_json
=
query_json
)
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
"Resolve
d
deleted Successfully"
)
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
"Resolve
r data
deleted Successfully"
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
debug
(
"Exception occurred while deleting Resolver data"
+
str
(
e
))
logger
.
debug
(
"Exception occurred while deleting Resolver data"
+
str
(
e
))
return
final_json
return
final_json
...
...
scripts/core/handler/supportcase_setup_handler.py
View file @
93b0c18b
...
@@ -108,7 +108,7 @@ class TicketSetupHandler:
...
@@ -108,7 +108,7 @@ class TicketSetupHandler:
user_data
=
self
.
mongo_obj
.
find_one
(
db_name
=
DBMapping
.
ilens_configuration
,
user_data
=
self
.
mongo_obj
.
find_one
(
db_name
=
DBMapping
.
ilens_configuration
,
collection_name
=
DBMapping
.
user
,
collection_name
=
DBMapping
.
user
,
query
=
{
"user_id"
:
user
[
"user_id"
]})
query
=
{
"user_id"
:
user
[
"user_id"
]})
user
=
dict
(
userName
=
user_data
[
"username"
],
user_id
=
user
)
user
=
dict
(
userName
=
user_data
[
"username"
],
user_id
=
user
.
get
(
"user_id"
)
)
if
input_json
[
"type"
]
==
"create"
:
if
input_json
[
"type"
]
==
"create"
:
case_id
=
"case_"
+
self
.
new_id
.
get_next_id
(
"case"
)
case_id
=
"case_"
+
self
.
new_id
.
get_next_id
(
"case"
)
else
:
else
:
...
@@ -167,10 +167,17 @@ class TicketSetupHandler:
...
@@ -167,10 +167,17 @@ class TicketSetupHandler:
last_updated_by
=
user
,
last_updated_by
=
user
,
user_details
=
input_json
[
"contacts"
]
user_details
=
input_json
[
"contacts"
]
)
)
if
"model"
in
input_json
:
if
input_json
[
"model"
]
.
lower
()
==
"view"
:
case_data
.
update
(
comments
=
input_json
.
get
(
"comments"
),
assigned_to
=
input_json
.
get
(
"assign"
),
case_status
=
input_json
.
get
(
"status"
),
emailIds
=
input_json
.
get
(
"email"
),
phoneNumbers
=
input_json
[
"phoneNumber"
])
self
.
mongo_obj
.
update_one
(
db_name
=
DBMapping
.
support_lens_configuration
,
self
.
mongo_obj
.
update_one
(
db_name
=
DBMapping
.
support_lens_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
,
set_json
=
case_data
,
query
=
query_json
)
set_json
=
case_data
,
query
=
query_json
)
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
"Casedata saved successfully"
)
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
"Case
data saved successfully"
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
"Exception while saving ticket data"
+
str
(
e
))
logger
.
exception
(
"Exception while saving ticket data"
+
str
(
e
))
return
final_json
return
final_json
...
@@ -222,6 +229,25 @@ class TicketSetupHandler:
...
@@ -222,6 +229,25 @@ class TicketSetupHandler:
def
fetch_ticket_details
(
self
,
input_json
):
def
fetch_ticket_details
(
self
,
input_json
):
final_json
=
dict
(
status
=
StatusMessages
.
FAILED
,
message
=
StatusMessages
.
FAILED
,
data
=
list
())
final_json
=
dict
(
status
=
StatusMessages
.
FAILED
,
message
=
StatusMessages
.
FAILED
,
data
=
list
())
try
:
try
:
query_json
=
{
'_id'
:
0
,
'category'
:
"$category_id"
,
'subCategory'
:
'$sub_category_id'
,
'site'
:
'$site_id'
,
'subject'
:
"$subject"
,
'fileNameBlock'
:
'$file_details'
,
'description'
:
'$Description'
,
'contacts'
:
'$user_details'
,
}
if
"model"
in
input_json
:
if
input_json
[
"model"
]
.
lower
()
==
"view"
:
query_json
.
update
({
"status"
:
"$case_status"
,
"assign"
:
"$assigned_to"
,
"comments"
:
"$comments"
,
"phoneNumber"
:
"$phoneNumbers"
,
"email"
:
"$emailIds"
})
response_data
=
list
(
self
.
mongo_obj
.
aggregate
(
response_data
=
list
(
self
.
mongo_obj
.
aggregate
(
db_name
=
DBMapping
.
support_lens_configuration
,
db_name
=
DBMapping
.
support_lens_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
,
...
@@ -231,18 +257,10 @@ class TicketSetupHandler:
...
@@ -231,18 +257,10 @@ class TicketSetupHandler:
'case_id'
:
input_json
[
"case_id"
]
'case_id'
:
input_json
[
"case_id"
]
}
}
},
{
},
{
'$project'
:
{
'$project'
:
query_json
'_id'
:
0
,
'category'
:
"$category_id"
,
'subCategory'
:
'$sub_category_id'
,
'site'
:
'$site_id'
,
'subject'
:
"$subject"
,
'fileNameBlock'
:
'$file_details'
,
'description'
:
'$Description'
,
'contacts'
:
'$user_details'
,
}
}
}
]))
]))
if
len
(
response_data
):
if
len
(
response_data
):
response_data
=
response_data
[
0
]
response_data
=
response_data
[
0
]
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
StatusMessages
.
SUCCESS
,
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
StatusMessages
.
SUCCESS
,
...
@@ -252,55 +270,188 @@ class TicketSetupHandler:
...
@@ -252,55 +270,188 @@ class TicketSetupHandler:
logger
.
exception
(
"Exception while fetching case details"
+
str
(
e
))
logger
.
exception
(
"Exception while fetching case details"
+
str
(
e
))
return
final_json
return
final_json
def
delete_case_details
(
self
,
input_json
):
def
delete_
support_
case_details
(
self
,
input_json
):
try
:
try
:
if
"case_id"
in
input_json
and
input_json
[
"case_id"
]
!=
""
:
response
=
self
.
update_case_status
(
case_id
=
input_json
[
"case_id"
],
status_value
=
CaseStatus
.
DELETED
)
query
=
{
"case_id"
:
input_json
[
"case_id"
]}
new_values
=
{
"$set"
:
{
"case_status"
:
CaseStatus
.
DELETE
}}
ConnectionObj
.
mongo_connection_obj
.
update_one
(
db_name
=
DBMapping
.
support_lens_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
,
query
=
query
,
set_json
=
new_values
)
return
{
"status"
:
"success"
,
"message"
:
"Case deleted successfully"
}
return
{
"status"
:
"success"
,
"message"
:
"Case deleted successfully"
}
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
str
(
e
))
logger
.
exception
(
str
(
e
))
return
{
"status"
:
"failed"
,
"message"
:
str
(
e
)}
return
{
"status"
:
"failed"
,
"message"
:
str
(
e
)}
def
get_support_case_table_details
(
self
,
input_json
):
def
resolve_support_case_details
(
self
,
input_json
):
try
:
response
=
self
.
update_case_status
(
case_id
=
input_json
[
"case_id"
],
status_value
=
CaseStatus
.
RESOLVED
)
return
{
"status"
:
"success"
,
"message"
:
"Case resolved successfully"
}
except
Exception
as
e
:
logger
.
exception
(
str
(
e
))
return
{
"status"
:
"failed"
,
"message"
:
str
(
e
)}
def
close_case_details
(
self
,
input_json
):
try
:
try
:
final_json
=
dict
(
status
=
StatusMessages
.
FAILED
,
message
=
StatusMessages
.
FAILED
,
response
=
self
.
update_case_status
(
case_id
=
input_json
[
"case_id"
],
status_value
=
CaseStatus
.
CLOSED
)
data
=
dict
(
tableData
=
dict
(
headerContent
=
StaticJsons
.
SUPPORTLENS_FETCHTABLE_HEADERCONTENT
),
return
{
"status"
:
"success"
,
"message"
:
"Case closed successfully"
}
tableActions
=
StaticJsons
.
SUPPORTLENS_FETCHTABLE_TABLEACTIONS
,
except
Exception
as
e
:
enableRowExpand
=
True
,
table_type
=
"infinite_scroll"
,
hideSearch
=
True
,
server_search
=
True
))
logger
.
exception
(
str
(
e
))
return
{
"status"
:
"failed"
,
"message"
:
str
(
e
)}
@
staticmethod
def
update_case_status
(
case_id
,
status_value
):
try
:
query
=
{
"case_id"
:
case_id
}
new_values
=
{
"$set"
:
{
"case_status"
:
status_value
}}
ConnectionObj
.
mongo_connection_obj
.
update_one
(
db_name
=
DBMapping
.
support_lens_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
,
query
=
query
,
set_json
=
new_values
)
return
True
except
Exception
as
e
:
logger
.
error
(
f
"Exception occurred while updating case status {str(e)}"
,
exc_info
=
True
)
return
False
def
get_support_case_table_details
(
self
,
input_json
):
final_json
=
dict
(
status
=
StatusMessages
.
FAILED
,
message
=
StatusMessages
.
FAILED
,
data
=
dict
(
tableData
=
dict
(
headerContent
=
StaticJsons
.
SUPPORTLENS_FETCHTABLE_HEADERCONTENT
),
tableActions
=
StaticJsons
.
SUPPORTLENS_FETCHTABLE_TABLEACTIONS
,
enableRowExpand
=
True
,
table_type
=
"infinite_scroll"
,
hideSearch
=
True
,
server_search
=
True
))
try
:
json_data
=
[
{
'$match'
:
{
'project_id'
:
input_json
[
"project_id"
],
'case_status'
:
input_json
[
"tab_name"
]
}
},
{
'$project'
:
{
'_id'
:
0
,
'case_id'
:
'$case_id'
,
'status'
:
'$case_status'
,
"subject"
:
'$subject'
,
"ProjectName"
:
"$ProjectName"
,
'last_updated_on'
:
'$last_updated_on'
,
'created_by'
:
'$created_by'
}
},
{
'$limit'
:
input_json
[
"records"
]
},
{
'$skip'
:
int
(
input_json
[
"records"
])
*
(
int
(
input_json
[
"page"
])
-
1
)
}
]
if
input_json
[
"filters"
]:
for
key
,
value
in
input_json
[
"filters"
]
.
items
():
if
value
not
in
[
""
,
None
,
str
()]:
if
key
==
"created_by"
:
json_data
[
0
][
"$match"
]
.
update
(
{
f
"{key}.userName"
:
{
"$regex"
:
f
"{value}"
,
'$options'
:
"i"
}})
elif
key
==
"last_updated_on"
:
json_data
[
0
][
"$match"
]
.
update
(
{
key
:
{
"$gte"
:
value
[
0
]
/
1000
,
'$lte'
:
value
[
-
1
]
/
1000
}})
else
:
json_data
[
0
][
"$match"
]
.
update
(
{
key
:
{
"$regex"
:
f
"{value}"
,
'$options'
:
"i"
}})
records
=
list
(
self
.
mongo_obj
.
aggregate
(
records
=
list
(
self
.
mongo_obj
.
aggregate
(
db_name
=
DBMapping
.
support_lens_configuration
,
db_name
=
DBMapping
.
support_lens_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
,
list_for_aggregation
=
[
list_for_aggregation
=
json_data
))
{
json_data
.
pop
(
3
)
'$match'
:
{
json_data
.
pop
(
2
)
'project_id'
:
input_json
[
"project_id"
]
total_records
=
list
(
self
.
mongo_obj
.
aggregate
(
}
db_name
=
DBMapping
.
support_lens_configuration
,
},
{
collection_name
=
DBMapping
.
ticket_configuration
,
'$project'
:
{
list_for_aggregation
=
json_data
))
'_id'
:
0
,
users_list
=
list
()
'case_number'
:
'$case_id'
,
'status'
:
'$case_status'
,
"subject"
:
'$subject'
,
"customer_project_id"
:
"$ProjectName"
,
'last_updated'
:
'$last_updated_on'
,
'created_by'
:
'$created_by'
}
}
]))
for
record
in
records
:
for
record
in
records
:
record
[
"created_by"
]
=
record
[
"created_by"
][
"userName"
]
record
[
"created_by"
]
=
record
[
"created_by"
][
"userName"
]
.
replace
(
"_"
,
" "
)
.
replace
(
"-"
,
" "
)
.
title
()
record
[
"last_updated
"
]
=
datetime
.
fromtimestamp
(
record
[
"last_updated
"
])
.
strftime
(
"
%
d
%
b
%
Y,
%
H:
%
M"
)
record
[
"last_updated
_on"
]
=
datetime
.
fromtimestamp
(
record
[
"last_updated_on
"
])
.
strftime
(
"
%
d
%
b
%
Y,
%
H:
%
M"
)
record
[
"expandData"
]
=
[{
"label"
:
str
(
key
)
.
replace
(
"_"
,
" "
)
.
replace
(
"-"
,
" "
)
.
title
(),
"value"
:
value
}
record
[
"expandData"
]
=
[{
"label"
:
str
(
key
)
.
replace
(
"_"
,
" "
)
.
replace
(
"-"
,
" "
)
.
title
(),
"value"
:
value
}
for
key
,
value
in
record
.
items
()]
for
key
,
value
in
record
.
items
()]
if
record
[
"created_by"
]
not
in
users_list
:
users_list
.
append
(
record
[
"created_by"
])
users_data
=
deepcopy
(
final_json
[
"data"
][
"tableData"
][
"headerContent"
][
-
2
])
users_data
[
"options"
]
=
[{
"label"
:
str
(
user
)
.
replace
(
"_"
,
" "
)
.
replace
(
"-"
,
" "
)
.
title
(),
"value"
:
user
}
for
user
in
users_list
]
final_json
[
"data"
][
"tableData"
][
"headerContent"
][
-
2
]
=
deepcopy
(
users_data
)
final_json
.
update
(
status
=
StatusMessages
.
SUCCESS
,
message
=
StatusMessages
.
SUCCESS
)
final_json
.
update
(
status
=
StatusMessages
.
SUCCESS
,
message
=
StatusMessages
.
SUCCESS
)
final_json
[
"data"
][
"tableData"
]
.
update
(
bodyContent
=
deepcopy
(
records
))
final_json
[
"data"
][
"tableData"
]
.
update
(
bodyContent
=
deepcopy
(
records
))
final_json
[
"data"
][
"total_no"
]
=
len
(
records
)
final_json
[
"data"
][
"total_no"
]
=
len
(
total_records
)
if
len
(
total_records
)
>=
(
int
(
input_json
[
"records"
])
*
int
(
input_json
[
"page"
])):
final_json
[
"end_of_records"
]
=
True
else
:
final_json
[
"end_of_records"
]
=
False
if
input_json
[
"enable_tab"
]:
final_json
[
"tab_count"
]
=
self
.
get_case_count_details
(
input_json
=
input_json
,
filter_value
=
"support_lens_table_header_content"
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
str
(
e
))
logger
.
exception
(
str
(
e
))
return
final_json
return
final_json
def
get_dashboard_details
(
self
,
input_json
):
final_json
=
dict
(
status
=
StatusMessages
.
FAILED
,
message
=
StatusMessages
.
FAILED
,
data
=
dict
())
try
:
final_json
[
"data"
][
"caseStatus"
]
=
self
.
get_case_count_details
(
input_json
=
input_json
,
filter_value
=
"support_lens_dashboard_header_content"
)
final_json
[
"data"
][
"chartData"
]
=
self
.
get_chart_details
(
input_json
)
final_json
.
update
(
status
=
"success"
,
message
=
"success"
)
except
Exception
as
e
:
logger
.
exception
(
str
(
e
))
return
final_json
def
get_chart_details
(
self
,
input_json
):
try
:
chart_json
=
self
.
get_case_count_details
(
input_json
=
input_json
,
filter_value
=
"support_lens_chart_header_content"
)
total_count
=
0
for
chart
in
chart_json
:
chart
[
"value"
]
=
chart
.
pop
(
"count"
)
total_count
+=
chart
[
"value"
]
for
data
in
chart_json
:
data
[
"percentage"
]
=
f
"{round(float((data['value'] / total_count) * 100), 2)}
%
"
return
chart_json
except
Exception
as
e
:
logger
.
exception
(
str
(
e
))
return
dict
()
def
get_case_count_details
(
self
,
input_json
,
filter_value
):
final_json
=
dict
(
status
=
StatusMessages
.
SUCCESS
,
message
=
StatusMessages
.
SUCCESS
,
data
=
dict
())
count_json_header_content
=
deepcopy
(
StaticJsons
.
SUPPORTLENS_HEADER_CONTENT
[
filter_value
])
try
:
json_data
=
[
{
'$match'
:
{
'project_id'
:
input_json
[
"project_id"
]
}
},
{
"$group"
:
{
"_id"
:
"$"
+
"case_status"
,
"totalCount"
:
{
"$sum"
:
1
}
}
}
]
count_json
=
{
CaseStatus
.
DELETED
:
0
,
CaseStatus
.
OPEN
:
0
,
CaseStatus
.
CLOSED
:
0
,
CaseStatus
.
RESOLVED
:
0
,
CaseStatus
.
REPLIED
:
0
,
CaseStatus
.
ASSIGNED
:
0
,
CaseStatus
.
RE_ASSIGNED
:
0
}
case_data
=
self
.
mongo_obj
.
aggregate_query
(
json_data
=
json_data
,
database_name
=
DBMapping
.
support_lens_configuration
,
collection_name
=
DBMapping
.
ticket_configuration
)
for
each_case
in
case_data
:
count_json
.
update
({
each_case
[
"_id"
]:
each_case
[
"totalCount"
]})
for
header
in
count_json_header_content
:
if
header
[
"key"
]
in
count_json
:
header
[
"count"
]
=
count_json
[
header
[
"key"
]]
final_json
[
"data"
]
=
deepcopy
(
count_json_header_content
)
except
Exception
as
e
:
logger
.
exception
(
str
(
e
))
return
final_json
[
"data"
]
scripts/core/services/supportcase_setup_configuration.py
View file @
93b0c18b
...
@@ -35,28 +35,64 @@ def fetch_support_case_details():
...
@@ -35,28 +35,64 @@ def fetch_support_case_details():
return
final_json
return
final_json
@
supportcase_setup_configuration
.
route
(
Endpoints
.
delete_
support_case
,
methods
=
[
'POST'
])
@
supportcase_setup_configuration
.
route
(
Endpoints
.
delete_
case_details
,
methods
=
[
'POST'
])
@
apply_encryption
@
apply_encryption
def
delete_
support_
case_details
():
def
delete_case_details
():
final_json
=
{
"status"
:
StatusMessages
.
FAILED
,
"message"
:
StatusMessages
.
SUPPORTCASE
_SAVE
}
final_json
=
{
"status"
:
StatusMessages
.
FAILED
,
"message"
:
StatusMessages
.
SUPPORTCASE
}
try
:
try
:
input_data
=
request
.
data
input_data
=
request
.
data
# input_data = request.get_json()
# input_data = request.get_json()
final_json
=
handler_obj
.
delete_case_details
(
input_data
)
final_json
=
handler_obj
.
delete_
support_
case_details
(
input_data
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
"Exception ->
%
s"
%
str
(
e
))
logger
.
exception
(
"Exception ->
%
s"
%
str
(
e
))
return
final_json
return
final_json
@
supportcase_setup_configuration
.
route
(
Endpoints
.
resolve_case_details
,
methods
=
[
'POST'
])
@
apply_encryption
def
resolve_case_details
():
final_json
=
{
"status"
:
StatusMessages
.
FAILED
,
"message"
:
StatusMessages
.
SUPPORTCASE
}
try
:
input_data
=
request
.
data
# input_data = request.get_json()
final_json
=
handler_obj
.
resolve_support_case_details
(
input_data
)
except
Exception
as
e
:
logger
.
exception
(
"Exception ->
%
s"
%
str
(
e
))
return
final_json
@
supportcase_setup_configuration
.
route
(
Endpoints
.
close_case_details
,
methods
=
[
'POST'
])
@
apply_encryption
def
close_case_details
():
final_json
=
{
"status"
:
StatusMessages
.
FAILED
,
"message"
:
StatusMessages
.
SUPPORTCASE
}
try
:
input_data
=
request
.
data
# input_data = request.get_json()
final_json
=
handler_obj
.
close_case_details
(
input_data
)
except
Exception
as
e
:
logger
.
exception
(
"Exception ->
%
s"
%
str
(
e
))
return
final_json
@
supportcase_setup_configuration
.
route
(
Endpoints
.
get_support_case_table_details
,
methods
=
[
'POST'
])
@
supportcase_setup_configuration
.
route
(
Endpoints
.
get_support_case_table_details
,
methods
=
[
'POST'
])
@
apply_encryption
@
apply_encryption
def
get_support_case_table_details
():
def
get_support_case_table_details
():
final_json
=
{
"status"
:
StatusMessages
.
FAILED
,
"message"
:
StatusMessages
.
SUPPORTCASE_
SAVE
}
final_json
=
{
"status"
:
StatusMessages
.
FAILED
,
"message"
:
StatusMessages
.
SUPPORTCASE_
FETCH
}
try
:
try
:
input_data
=
request
.
data
input_data
=
request
.
data
# input_data = request.get_json()
# input_data = request.get_json()
final_json
=
handler_obj
.
get_support_case_table_details
(
input_data
)
final_json
=
handler_obj
.
get_support_case_table_details
(
input_data
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
"Exception ->
%
s"
%
str
(
e
))
logger
.
exception
(
"Exception ->
%
s"
%
str
(
e
))
return
final_json
return
final_json
\ No newline at end of file
@
supportcase_setup_configuration
.
route
(
Endpoints
.
get_dashboard_details
,
methods
=
[
'POST'
])
@
apply_encryption
def
get_dashboard_details
():
final_json
=
{
"status"
:
StatusMessages
.
FAILED
,
"message"
:
StatusMessages
.
SUPPORTCASE_DASHBOARD
}
try
:
input_data
=
request
.
data
# input_data = request.get_json()
final_json
=
handler_obj
.
get_dashboard_details
(
input_data
)
except
Exception
as
e
:
logger
.
exception
(
"Exception ->
%
s"
%
str
(
e
))
return
final_json
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