{
    "schema": "1.0",
    "key": "compute-the-average-resolution-time-of-comment-threads-per-partner",
    "title": "Compute the average resolution time of comment threads per partner",
    "tasks": [
        {
            "name": "context-user-get",
            "taskReferenceName": "fetch_current_user",
            "description": "Fetch current user",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {}
        },
        {
            "name": "data-comment-thread-find",
            "taskReferenceName": "fetch_comment_threads",
            "description": "Fetch comment threads",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "findMode": "ALL"
            }
        },
        {
            "name": "data-account-find",
            "taskReferenceName": "fetch_accounts",
            "description": "Fetch accounts",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "findMode": "ALL"
            }
        },
        {
            "name": "json-transform-jq",
            "taskReferenceName": "compute_filter_comment_threads_closed",
            "description": "Filter comment threads opened and assigned to my account",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "data": {
                    "accountId": "${workflow.input.context.userAccountId}",
                    "commentThreads": "${fetch_comment_threads.output.json}"
                },
                "queryExpression": ".data.accountId as $accountId | .data.commentThreads[] | select(.isClosed == true)"
            }
        },
        {
            "name": "file-conversion-json-to-xml",
            "taskReferenceName": "convert_comment_threads",
            "description": "JSON to XML conversion of comment threads",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "JSON",
                "json": "${compute_filter_comment_threads_closed.output.resultList}"
            }
        },
        {
            "name": "file-conversion-json-to-xml",
            "taskReferenceName": "counvert_accounts",
            "description": "JSON to XML conversion of accounts",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "JSON",
                "json": "${fetch_accounts.output.json}"
            }
        },
        {
            "name": "file-transformation-xslt",
            "taskReferenceName": "file_transformation_xslt",
            "description": "Generate Email Body",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "FILE",
                "file": "${convert_comment_threads.output.file}",
                "xslt": "file://assets/generate-email.xslt",
                "fileName": "result.xml",
                "params": [
                    {
                        "name": "domain",
                        "select": "app.dev.product-live.com"
                    },
                    {
                        "name": "userEmail",
                        "select": "${fetch_current_user.output.json.email}"
                    },
                    {
                        "name": "accountFile",
                        "select": "${counvert_accounts.output.file}"
                    },
                    {
                        "name": "userAccountId",
                        "select": "${workflow.input.context.userAccountId}"
                    }
                ]
            }
        },
        {
            "name": "notification-display-message",
            "taskReferenceName": "notification_display_message",
            "description": "Display Message",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "request": "${file_transformation_xslt.output.file}",
                "height": 300
            }
        },
        {
            "name": "notification-send-email",
            "taskReferenceName": "notification_send_email",
            "description": "Send Email",
            "optional": true,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "FILE",
                "file": "${file_transformation_xslt.output.file}"
            }
        }
    ],
    "outputParameters": {
        "email": "${file_transformation_xslt.output.file}",
        "threads": "${filter_comment_threads_closed.output.resultList}",
        "message": "${notification_display_message.output.message}"
    }
}
