Insight Functions

The class Adp.Insight is used for working with insights.

Generation of insight is performed in background and requires checking for the completion.

Insight.insight(av_name, measure,job_owner=None,source_owner=None)

This generates insight of the measure for the Analytic view.

Here are the fields and their description:

av_name: This field is a name of the Analytic view.

measure: This is the name of the measure of the Analytic view.

job_owner: This is the schema name of the job.

object_owner: This is the schema name of the object. None as one or two owners means that the current schema is used.

Insight.get_job_status(request_name,owner=None)

The above function returns the list of status of insights request. The owner is schema name of the insight (None means that the current schema is used). The generation of insights finishes when field insight_job_status is COMPLETED.

Insight.drop(request_name)

The above function is a Drop insight request.

Insight.get_request_list(owner=None)

The above function returns the json list of request names and their parameters where owner is a schema name of the requests. None means that the current schema is used.

Insight.get_insights_list(requestName)

The above function returns the json list of insights. Each insight has the following fields:

insight_name, visualization_id, insight_column, insight_value, insight_dimension and dimension.

Insight.get_graph_details(name, id, count=0, query_manipulation=None, owner=None)

The above function returns JSON data dictionary of data plotted.

Here are the parameters with their descriptions:

name: This is the insight name.

id: This is visualization id.

If query_manipulation is not None, add cursor type and grand totals fields to the query.

owner: This is a schema name of the insight (None means that the current schema is used).

Results consists of two fields:item contains overall information from the insight: description, XAXIS, measure, insight_type_label, visualization_condition, source_object.

query contains information for plotting and has three lists: labels, actuals and estimates.

Examples of Insight

This section provides the following examples to help you get started using the Insight API:

  • Generate of insight
  • Drop the insight
  • List of insight requests
  • List of insights
  • Check the completion of insight
  • Get Data from the visualization view

Before using these examples, you must create an ADP instance and connect to the ORDS:

import adp

ords = adp.login('<protocol://host:port>', 'schema_name', 'schema_password')

Generate of insight

ords.Insight.generate('SALES_AV', 'AMOUNT_SOLD')

Output:

{

  "object_owner": "ADPTEST",

  "request_name": "REQUEST_INSIGHT_1",

  "max_insight_count": 20,

  "source_object": "SALES_AV",

  "source_owner": "SALES_AV",

  "request_metadata": "{\"targets\":[\"AMOUNT_SOLD\"],\"appName\":\"INSIGHTS\"}",

  "default_job_settings": "{\"insightTypes\":[\"FITTED_SHARE_COMPARISON\"]}",

  "new_request": "true"

}

Drop the insight

ords.Insight.drop('REQUEST_INSIGHT_1')

List of insight requests

ords.Insight.get_request_list()



Output:

[

  ... 

  {

    "owner": "ADMIN",

    "request_name": "REQUEST_INSIGHT_1",

    "request_type": "TABLE_INSIGHT",

    "source_object": "SALES",

    "source_owner": "ADMIN",

    "request_metadata": "{\"targets\":[\"ACTUAL\"],\"appName\":\"INSIGHTS\"}",

    "created": "2022-10-31T08:03:26.634Z",

    "updated": "2022-10-31T08:03:26.634Z",

    "request_job_setting": "{\"EXTRACTION\":{\"selectionRule\":{\"value\":\"MAX_DIFFERENCE\"},\"fittedShareConvergence\":{\"value\":\"LAX\"},\"maxNumExtractionDims\":{\"value\":10000},\"insightValueType\":{\"value\":\"MEMBER\"},\"excludeZero\":{\"value\":\"YES\"},\"minXAxisCount\":{\"value\":2}},\"sessionId\":null,\"applicationName\":\"INSIGHTS\",\"insightTypes\":[\"FITTED_SHARE_COMPARISON\"]}",

    "max_num_insights": 20

  },

  ...

]
List of insights
ords.Insight.get_insights_list('REQUEST_INSIGHT_1')

Output:

[

  {

    "insight_name": "INSIGHT_62",

    "visualization_id": 199,

    "insight_column": "ACTUAL",

    "insight_value": "COUNTRY.2",

    "insight_dimension": "COUNTRY",

    "dimension": "FORECST"

  },..

]

Check the completion of insight

ords.Insight.get_job_status('REQUEST_INSIGHT_1')



Output:



{

  "insight_job_status": "COMPLETED",

  "progress_msg": " ",

  "error_msg": null

}

Get Data from the visualization view

ords.Insight.get_graph_details("INSIGHT_62", 199, 5, True)



Output:

{

  "items": {

    "description": "COUNTRY.2",

    "XAXIS": "FORECST",

    "measure": "ACTUAL",

    "insight_type_label": "Expected",

    "visualization_condition": "COUNTRY.2",

    "source_object": "C0"

  },

  "query": {

    "labels": [

      "01:[66.7-1590]",

      "02:[829-2350]",

      "04:[2350-3870]",

      "06:[3870-5390]",

      "07:[4630-6150]"

    ],

    "actuals": [

      2200,

      6200,

      24600,

      26600,

      14200

    ],

    "estimates": [

      2671.105013588167,

      4830.820533674098,

      7135.506976989193,

      24772.963909661587,

      22121.48462234561

    ]

  }

}