Versions Compared

Key

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

...

We need to include Batch Status attribute in response of API to fetch user enrolled courses (/course/v1/user/enrollment/list/{‌{userId}‌}).

Terminology :

  1. Metadata Batch data/batch : This term refers the data related to course batch which will be added in response specifically in batchMetaDatabatch
  2. Standard supported Metadata batch data : This term refers the standard data which will be provided irrespective of the query parameter for "batchDetailsfields". For example we can consider batchName, batchStartDate,bacthEndDate as standard metadata batch data for batchDetails.
  3. Standard supported fields : This term refers field which are supported by API to get in "batchMetaData batch " map . Standard supported fields can be the fields which exist in course batch objects and are not sensitive for exposure.

...

API will accept a new query parameter as batchDetailsfields=status  and based on that it will add batch status inside response.

...

ProsCons
Separation of the query param. Ex: OrgDetails is for org and batchDetails fields is for batch

response will have separate metadata attributes as "batchMetaDatabatch", So that later we can add more attribute.


...

  1. Before returning the response , we will iterate over courses objects.
  2. Get batchId from each courses Object and call API to get bulk batch Details.
  3. We will again iterate over UserCourses Object and append the required meta batch data.
  4. Do it for all courses Object.
  5. return the response.

...

Get  ../course/v1/user/enrollment/list/{‌{userId}‌}&orgdetails=name,status&batchDetailsfields=name,startDate,EndDate,status.

...

Code Block
languagejs
{
  "id": "api.user.courses.list",
  "ver": "v1",
  "ts": "2018-11-15 09:17:31:909+0000",
  "params": {
    "resmsgid": null,
    "msgid": "9db786d3-45c2-447d-b657-f9768da15652",
    "err": null,
    "status": "success",
    "errmsg": null
  },
  "responseCode": "OK",
  "result": {
    "courses": [
      {
        "dateTime": "2018-07-04 09:31:22:294+0000",
        "status": 1,
         ...
        "batchMetaDatabatch": {
          "name": "batchName",
          "startDate": "2018-01-02",
          "endDate": "2018-01-22",
          "status": "1"
        }
      },
      {
        ...
        }
      }
    ]
  }
}

...

ProsCons
  •  Addition of only standard meta batch data for course batches, fast and specific.
  • If need to get more meta batch data other than standard supported metadata batch data , code changes or schema in data bases will have to be upgraded.
  • No need to check for other data in request parameter.
  • Some time standard supported metadata batch data may contain useless data for an specific request. ex: only batch status is required but some other standard details are also returned in response.(batchName,startDate)

...

  1. Before returning the response , we will iterate over courses objects.
  2. Get batchId and call API to get batch Details.
  3. Create and populate batchMetaData batch data Map with the standard supported metadata batch data fields.
  4. Standard metadata bath data fields can be cached in DataCacheHandler . DataCacheHandler will be initialized from a database query from cassandra.
  5. Using cassandra will give us freedom to add or remove fields from standard metadata fields.
  6. Append it to the coursesObject.
  7. Do it for all courses Object.
  8. Return the response.

Instead of making API call for getting batchDetails fields on at a time we can do it by sending list of coursebatchIds so only one API call will be there but it can increase complexity of code and performance also.

...

Code Block
languagejs
{
  "id": "api.user.courses.list",
  "ver": "v1",
  "ts": "2018-11-15 09:17:31:909+0000",
  "params": {
    "resmsgid": null,
    "msgid": "9db786d3-45c2-447d-b657-f9768da15652",
    "err": null,
    "status": "success",
    "errmsg": null
  },
  "responseCode": "OK",
  "result": {
    "courses": [
      {
        "dateTime": "2018-07-04 09:31:22:294+0000",
        ...
        "batchMetaDatabatch": {
          "name": "batchName",
          "startDate": "2018-01-02",
          "endDate": "2018-01-22",
          "status": "1",
         
        }
      },
     { }
    ]
  }
}

...

 Accepting attributes in request parameters and also providing standard metadatabatch data. If request parameter contains any other attribute different from standard meta data , the meta batch data map will also have the requested attributes with standard meta batch data.



ProsCons
  • This Hybrid of approaches mentioned above. So can return specific standard metadata batch data as well as requested metadata batch data about course batches in which user is enrolled.
  • Need to handle if request attribute is not supported or already present in standard metadatabatch data.
  • If any unsupported fields is requested, we can return "field not found" for "unsupported field name" as key  in the batch details meta data batch  map, which already containing standard metadatabatch data.
  • Some time standard supported metadata batch data may contain useless data for an specific request. ex: only batch status is required but some other standard details are also returned in response.(batchName,startDate)

...

1.Get  ../course/v1/user/enrollment/list/{‌{userId}‌}?orgDetails=name   response  will same as approach 2 in which only standard meta batch data will be return as no other attribute is mentioned in this request.

...

2. Get  ../course/v1/user/enrollment/list/{‌{userId}‌}?orgDetails=name,status&batchDetailsfields=name,someUnsupportedField.   Here we  already have  batch start date , end date and status is standard meta batch data.

Implementation details :

  1. Before returning the response , we will iterate over courses objects.
  2. Get batchId and call API to get batch Details.
  3. Create and populate batchMetaData batchData Map with the standard supported metadata fields.
  4. Standard metadata fields can be cached in DataCacheHandler . DataCacheHandler will be initialized from a database query from cassandra.
  5. Using cassandra will give us freedom to add or remove fields from standard metadata fields.
  6. Add the other requested data in the batchMetaData batchData map , if some unsupported field is in request neglect it or put some error message.(NOT_SUPPORTED).
  7. Append it to the coursesObject.
  8. Do it for all courses Object.
  9. Return the response.

...

Code Block
languagejs
{
    "id": "api.user.courses.list",
    "ver": "v1",
    "ts": "2018-11-15 09:17:31:909+0000",
    "params": {
        "resmsgid": null,
        "msgid": "9db786d3-45c2-447d-b657-f9768da15652",
        "err": null,
        "status": "success",
        "errmsg": null
    },
    "responseCode": "OK",
    "result": {
        "courses": [
            {
                "lastReadContentId": "do_21253529011637452811543",
                "courseId": "do_21253534443347968011561",
                "status": 1,
                "batchMetaDatabatch" :{ 
					"startDate":"2018-01-02",
					"endDate":"2018-01-22",
					"status" :"1",
					"name":"batchName",
					"someUnsupportedField":"NOT_SUPPORTED",
					 "someOtherKey": "someOtherValue"
				}
            },
            {
               
            }
        ]
    }
}

...