Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Overview

Need of Batch status attribute in response of {‌{url}‌}/course/v1/user/enrollment/list/{‌{userId}‌} API for each batch in which user is enrolled.


Terminology :

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

Approaches

Approach 1

API will accept a new query parameter as batchDetails=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 is for batch

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




Solution:

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 Map with the requested metadata attributes.
  4. Append it to the coursesObject.
  5. Do it for all courses Object.
  6. return the response.


                                

API to get user course enrollment list

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

Resopnse :

{
  "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,
         ...
        "batchMetaData": {
          "name": "batchName",
          "startDate": "2018-01-02",
          "endDate": "2018-01-22",
          "status": "1"
        }
      },
      {
        ...
        }
      }
    ]
  }
}


Approach 2

Not accepting any attribute value in request parameters , returning standard supported fields for the course batches in which user is enrolled.


ProsCons
  •  Addition of only standard meta data for course batches, fast and specific.
  • If need to get more meta data other than standard supported metadata , 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 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)


Solution:

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 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. Append it to the coursesObject.
  7. Do it for all courses Object.
  8. Return the response.

Instead of making API call for getting batchDetails 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.

API to get user course enrollment list

Get  ../course/v1/user/enrollment/list/{‌{userId}‌}?orgDetails=orgName


Response :

{
  "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",
        ...
        "batchMetaData": {
          "name": "batchName",
          "startDate": "2018-01-02",
          "endDate": "2018-01-22",
          "status": "1",
         
        }
      },
     { }
    ]
  }
}


Approach 3

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



ProsCons
  • This Hybrid of approaches mentioned above. So can return specific standard metadata as well as requested metadata about course batches in which user is enrolled.
  • Need to handle if request attribute is not supported or already present in standard metadata.
  • If any unsupported fields is requested, we can return "field not found" for "unsupported field name" as key  in the batch details meta data map, which already containing standard metadata.
  • Some time standard supported metadata 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)



Solution

API to get user course enrollment list

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



2. Get  ../course/v1/user/enrollment/list/{‌{userId}‌}?orgDetails=name,status&batchDetails=name,someUnsupportedField.   Here we  already have  batch start date , end date and status is standard meta 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 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 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.

Instead of making API call for getting batchDetails 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.

Responses

{
    "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,
                "batchMetaData" :{ 
					"startDate":"2018-01-02",
					"endDate":"2018-01-22",
					"status" :"1",
					"name":"batchName",
					"someUnsupportedField":"NOT_SUPPORTED",
					 "someOtherKey": "someOtherValue"
				}
            },
            {
               
            }
        ]
    }
}
  • No labels