...
We need to include Batch Status attribute in response of API to fetch user enrolled courses (/course/v1/user/enrollment/list/{{userId}}).
Terminology :
- Metadata Batch data/batch : This term refers the data related to course batch which will be added in response specifically in batchMetaDatabatch.
- 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.
- 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.
...
Pros | Cons |
---|---|
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. |
...
- Before returning the response , we will iterate over courses objects.
- Get batchId from each courses Object and call API to get bulk batch Details.
- We will again iterate over UserCourses Object and append the required meta batch data.
- Do it for all courses Object.
- return the response.
...
Get ../course/v1/user/enrollment/list/{{userId}}&orgdetails=name,status&batchDetailsfields=name,startDate,EndDate,status.
...
Code Block | ||
---|---|---|
| ||
{ "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" } }, { ... } } ] } } |
...
Pros | Cons |
---|---|
|
|
|
|
...
- Before returning the response , we will iterate over courses objects.
- Get batchId and call API to get batch Details.
- Create and populate batchMetaData batch data Map with the standard supported metadata batch data fields.
- Standard metadata bath data fields can be cached in DataCacheHandler . DataCacheHandler will be initialized from a database query from cassandra.
- Using cassandra will give us freedom to add or remove fields from standard metadata fields.
- Append it to the coursesObject.
- Do it for all courses Object.
- 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 | ||
---|---|---|
| ||
{ "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.
Pros | Cons |
---|---|
|
|
|
|
...
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 :
- Before returning the response , we will iterate over courses objects.
- Get batchId and call API to get batch Details.
- Create and populate batchMetaData batchData Map with the standard supported metadata fields.
- Standard metadata fields can be cached in DataCacheHandler . DataCacheHandler will be initialized from a database query from cassandra.
- Using cassandra will give us freedom to add or remove fields from standard metadata fields.
- 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).
- Append it to the coursesObject.
- Do it for all courses Object.
- Return the response.
...
Code Block | ||
---|---|---|
| ||
{ "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" } }, { } ] } } |
...