Skip to content

Commit

Permalink
[MyToDoTasksWidget] automation query bug fix (#27856)
Browse files Browse the repository at this point in the history
* Update search query; Update table name

* Update docker image

* Update release notes

* Remove ignore for RM109

* Add README.md file

* Ignore main function in UT coverage

* Add human readable output example
  • Loading branch information
samuelFain authored Jul 4, 2023
1 parent 087e76c commit 180a0a3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.
3 changes: 0 additions & 3 deletions Packs/CommonWidgets/.pack-ignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[file:MyToDoTasksWidget.yml]
ignore=RM109

[known_words]
GetLargestInvestigations
GetLargestInputsAndOutputsInIncidents
Expand Down
7 changes: 7 additions & 0 deletions Packs/CommonWidgets/ReleaseNotes/1_2_25.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#### Scripts

##### MyToDoTasksWidget

- Fixed an issue that prevented the script from showing open tasks for users who had a significant number of closed tasks assigned to them.
- Updated the Docker image to: *demisto/python3:3.10.12.63474*.
17 changes: 11 additions & 6 deletions Packs/CommonWidgets/Scripts/MyToDoTasksWidget/MyToDoTasksWidget.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
from dateparser import parse

import demistomock as demisto
from CommonServerPython import *
MAX_ENTRIES = 30


def get_open_to_do_tasks_of_current_user() -> List[Dict]:
body = {
"dataType": "todos",
"query": "assignee:\"{me}\"",
"widgetType": "table"
"query": "assignee:\"{me}\" and status:\"open\"",
"widgetType": "table",
"size": MAX_ENTRIES,
}
todo_tasks_query_res = demisto.internalHttpRequest(
'POST',
Expand Down Expand Up @@ -47,10 +49,13 @@ def get_open_to_do_tasks_of_current_user() -> List[Dict]:
return table


def main():
def main(): # pragma: no cover
try:
results = get_open_to_do_tasks_of_current_user()
table_name = f'My ToDo Tasks ({len(results)})'
if len(results) >= MAX_ENTRIES:
table_name = f'My ToDo Tasks (First {MAX_ENTRIES} Tasks)'
else:
table_name = f'My ToDo Tasks ({len(results)})'
readable_output = tableToMarkdown(table_name, results, headers=list(results[0].keys()) if results else None)
cmd_results = {
'Type': entryTypes['note'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags:
timeout: '0'
type: python
subtype: python3
dockerimage: demisto/python3:3.10.5.31928
dockerimage: demisto/python3:3.10.12.63474
fromversion: 6.1.0
tests:
- No test
26 changes: 26 additions & 0 deletions Packs/CommonWidgets/Scripts/MyToDoTasksWidget/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
A script that creates a table of all the ToDo tasks assigned to the current user.

## Script Data

---

| **Name** | **Description** |
| --- | --- |
| Script Type | python3 |
| Tags | widget |
| Cortex XSOAR Version | 6.1.0 |

## Inputs

---
There are no inputs for this script.

## Outputs

---
### Human Readable Output

>### My ToDo Tasks (1)
>|Task Name|Task Description|Task ID|SLA|Opened By|Incident ID|
>|---|---|---|---|---|---|---|
>| task | task description | 1@1 | 0001-01-01 00:00:00+0000 | user | 1 |
2 changes: 1 addition & 1 deletion Packs/CommonWidgets/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Common Widgets",
"description": "Frequently used widgets pack.",
"support": "xsoar",
"currentVersion": "1.2.24",
"currentVersion": "1.2.25",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 180a0a3

Please sign in to comment.