Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Purpose :

  • Design for Experiment API's to populate,list,delete the experiment definition
  • Design the experiment definition schema
  • Design Data product  to map  the users/devices to experiments

Design Flow :

Experiment API :

CREATE API  :

URL :  POST  /experiment/create

Input :

Sample User Criteria Input Request:

Code Block
themeRDark
titleUserType Request Body
  "request": {
    "expId": "U1234",                  // Unique Id for Experiment
    "name": "USER_ORG",                // Name for Experiment
    "createdBy": "User1",              // Name of the user who created this experiment
    "description": "Experiment to get users withto orgnameexplore =page sunbird",  // Short Description about the experiment
    "criteria": {                      // Criteria for the Experiment
      "type": "user",                  // Type of the Criteria
      "filters": {                     // ArrayPLEASE ofrefer Filtersthis Criterialink withfor Useruser Filtersearch field Name and List of Values
  filters- http://docs.sunbird.org/latest/apis/userapi/#operation/Search%20User
        "organisations.orgName": ["sunbird"] // List of Values
      }
    },
    "data" : {                         // Experiment Data 
      "startDate" : "2019-08-01",      // Start date of the Experiment
      "endDate" : "2019-08-02",        // End date of the Experiment
      "key" : "/org/profile",           // Experiment Key
    }   }"client" : "portal"              // name of the client (app/portal/desktop)  
    }
  }


Device Criteria Input Request:

Code Block
themeRDark
titleDeviceType Criteria Request Body
  "request": {
    "expId": "D1234",                  // Unique Id for Experiment
    "name": "Device_STATE_AP",         // Name for Experiment
    "createdBy": "User2",              // Name of the user who created this experiment
    "description": "Experiment to get devices with state = AndhraPradesh",  // Short Description about the experiment
    "criteria": {                      // Criteria for the Experiment
      "type": "device",                // Type of the Criteria 
      "filters": [
		{                     // Array of Filters
        "name": "state",               // Namestate offield the fieldcritera
        "operator": "IN",              // Filter Operator  - Supported Filters : [IN,EQ] 
        "value": ["Karnataka"]         // List of Values
        },
		{        },     "data" : {    // Experiment
Data        "startDatename" : "2019-08-01city",               // Startcity datefield ofcritera
the Experiment       "endDateoperator" : "2019-08-02IN",              // End date of the Experiment Filter Operator  - Supported Filters : [IN,EQ] 
        "keyvalue" : ["3fksjfksdlfjBangalore", ]         // ExperimentList Keyof Values
     "client" :  "app" },
		{               // T     
       }   }

Output :

  • Process the request and save the request parameters to Experiment-Definition Cassandra Table with status "SUBMITTED"
  • Response : "Experiment Submitted Sucessfully"

GET API  :

URL :  GET  /experiment/:id

Request Params :  ExperimentId

Repsonse :  Experiment Details for the respective experiment Id

Sample Response :

Code Block
themeRDark
titleSample Get API ReSposne
{
  "expId": "U1234",
  "expName": "USER_ORG",
  "expDescription": "Experiment to get users with orgname = sunbird",
  "expData": {"name": "first_access",     // device field criteria
          "operator": "RANGE",        // Filter Operator  -  Supported Filters : [RANGE,LT] 
          "value": {
            "startDatestart": "2019-0802-0110",
      "endDate      "end": "2019-0802-04",20"
        }
     ]
"key": "/org/profile"   },
    "createdBydata" : "User1", {    // Experiment Data 
  "updatedBy": "ExperimentDataProduct",   "udpatedOnstartDate" : "2019-08-02 19:00:0001",       "createdOn": "2019-08-01 10:00:00",
  "criteria": {// Start date of the Experiment
      "typeendDate" : "user2019-08-02",     "filter": {  // End date of  "organisations.orgName": [the Experiment
      "key"   : "sunbird3fksjfksdlfj",       ]   // Experiment }Key
  },   "status": "activeclient", :  "status_msgapp":  "Experiment is actively mapped",   "stats": {     "usersMatched": 234, // name of  "devicesMatched": 0the client (app/portal/desktop)
    }
  }

...

Device Filter Criteria  :

URL :  GET  /experiment/list

Output :  List of all Experiments

Sample Response :

Output :

  • Process the request and save the request parameters to Experiment-Definition Cassandra Table with status "SUBMITTED"
  • Response : "Experiment Submitted Sucessfully "

Note :

  • All fields are mandatory
  • Same Experiment will not be allowed to submit again unless the status of the experiment is FAILED
  • If the experiment is submitted more than once , will send a response "Experiment already submitted"

GET API 

URL :  GET  /experiment/:id

Request Params :  ExperimentId

Repsonse :  Experiment Details for the respective experiment Id

Sample Response :

Code Block
themeRDark
titleSample Get API ReSposne
{
  "expId": "U1234",
  "expName": "USER_ORG",
  "expDescription": "Experiment to get users with orgname = sunbird",
  "expData": {
    "startDate": "2019-08-01",
    "endDate": "2019-08-04",
    "key": "/org/profile"
  },
  "createdBy": "User1",
  "updatedBy": "ExperimentDataProduct",
  "udpatedOn": "2019-08-02 19:00:00",
  "createdOn": "2019-08-01 10:00:00",
  "criteria": {
    "type": "user",
    "filter": {
      "organisations.orgName": [
        "sunbird"
      ]
    }
  },
  "status": "active",
  "status_msg": "Experiment is actively mapped",
  "stats": {
    "usersMatched": 234,
    "devicesMatched": 0
  }
}


GET LIST  API  :

URL :  GET  /experiment/list

Output :  List of all Experiments

Sample Response :

{ "experiments": [ {
Code Block
themeRDark
titleSample Reponse Experiment List
Sample Reponse Experiment List
collapsetrue
{
  "experiments": [
    {
      "expId": "D1234",
      "expName": "DEVICE_STATE_ANDHRAPRADESH",
      "expDescription": "Experiment to get deviceids with first_access Sep1st to Sep3rd",
      "expIdexpData": "U1234", {
        "expNamestartDate": "USER_ORG2019-08-01",
        "expDescriptionendDate": "Experiment to get users with orgname = sunbird",
  "2019-08-04",
        "key": "/org/profile"
   "expData": {  },
      "startDatecreatedBy": "2019-08-01User6",
 
      "endDateupdatedBy": "2019-08-04ExperimentDataProduct",

       "keyudpatedOn": "/org/profile"
      }2019-08-02 19:00:00",
      "createdBycreatedOn": "User12019-07-04 10:00:00",
      "updatedBycriteria": "ExperimentDataProduct", {
        "udpatedOntype": "2019-08-02 19:00:00device",
        "createdOnfilter": "2019-08-01 10:00:00", {
          "criterianame": {"first_access",
          "typeoperator": "userRANGE",
          "filtervalue": {
            "organisations.orgNamestart": ["2019-02-10",
            "end": "sunbird2019-02-20"
          ]}
        }
      },
      "status": "activeFAILED",
      "status_msg": "Experiment is actively mappedDevices Not Found matching the Criteria",
      "stats": {
        "usersMatched": 2340,
        "devicesMatched": 0
      }
    },
    {
      "expId": "D1234U1234",
      "expName": "DEVICEUSER_STATE_ANDHRAPRADESHORG",
      "expDescription": "Experiment to get deviceidsusers with first_access Sep1st to Sep3rdorgname = sunbird",
      "expData": {
        "startDate": "2019-08-01",
        "endDate": "2019-08-04",
        "key": "/org/profile"
    
 },       "createdByclient": "User6app",
      "updatedBy": "ExperimentDataProduct"},
      "udpatedOn": "2019-08-02 19:00:00",
      "createdOn": "2019-07-04 10:00:00createdBy": "User1",
      "criteriaupdatedBy": {
 "ExperimentDataProduct",
      "typeudpatedOn": "device2019-08-02 19:00:00",

       "filtercreatedOn": {
  "2019-08-01 10:00:00",
       "namecriteria": "first_access",
 {
        "operatortype": "RANGEuser",
 
        "valuefilter": {
 
          "startorganisations.orgName": "2019-02-10",[
            "endsunbird":
"2019-02-20"           }]
        }
      },
      "status": "FAILEDactive",
      "status_msg": "DevicesExperiment Notis Found matching the Criteriaactively mapped",
      "stats": {
        "usersMatched": 0234,
        "devicesMatched": 0
      }
    }
  ]
}


Experiment Definition Schema:


FieldtypeDescription
1expIdStringunique id for experiment
2expNameStringname of the experiment
3expDescriptionStringdescirption of the experiment
4

expDataMap<String,String>

Experiment Data

  • startDate  - start date of the experiment
  • endDate - end date of the experiment
  • key/url  -  key or url of the experiment
  • modulus - mod number of the experiment
  • client - Name of the client for the experiment
5createdByStringname of the user who created the experiment
6updatedByStringname of product that last updated the experiment
7udpatedOnTimestamplast udpated date by the source
8createdOnTimestampcreated date for the experiment
9criteriaMap<String,String>

criteria of the experiment

  • type  - Type of Criteria (user/device)
  • filters - Array of Filters
10statusStringstatus of the experiment(SUBMITTED/PROCESSING/ACTIVE/FAILED/STOPPED/INACTIVE)
11status_messageStringstatus description of the experiment
11
12statsMap<String,Long>

Statistic Data

  • usersMatched
  • devicesMatched


Experiment Data Product :

Purpose

  • To compute the user/device experiment mapping based on the experiment criteria and save it to elastic search

Input:

  • Experiment_Definition Cassandra Table

Output 

User experiment mapping  index to elastic search

...