Versions Compared

Key

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

...

/course/v1/user/enrollment/list/{‌{userId}‌}?fields=[comma-seperated-valid-fields]&orgDetails=orgNamename,status&fields=status,anyotherfields

Terminology :

...

...

Approaches

Approach 1

API will accept a new query parameter as fields=status  and based on that it will add batch status inside response, where user can specify which batch fields need to be fetched along with enrolled courses.


response will have separate attributes as "batch", So that later we can add more attribute.
ProsCons
Separation of the query param. Ex: OrgDetails is for org and fields is for batchExplicit input for fields is required.

Gives flexibility for user to fetch batch fields as per requirement




Solution:

Implementation details :

  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.We will again iterate over UserCourses Object course object and collect all batchIds and fetch batch data in single call from ES.
  3. Iterate over courses object and append the required batch-data.
  4. Do it for all courses Object.
  5. return the response.

                                

...

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

...

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


Some time standard supported 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)
ProsCons
  •  Addition of only standard batch data for course batches, fast and specific.
  • If need to get more batch data other than standard supported batch data , code changes or schema in data bases will have to be upgraded.
  • No need to check for other data in request parameter.

User input not required

Requires code changes for getting additional fields in response in future.


Additional calls - regardless of whether user wants the additional data.

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 batch data Map with the standard supported batch data fields.
  4. Standard 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 batchdata 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 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 alsoSame as approach 1, except the fields of batch to be returned are hard-coded in code.

API to get user course enrollment list

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

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": [
      {
        "dateTime": "2018-07-04 09:31:22:294+0000",
        ...
        "batch": {
          "name": "batchName",
          "startDate": "2018-01-02",
          "endDate": "2018-01-22",
          "status": "1",
         
        }
      },
     { }
    ]
  }
}

...

2. Get  ../course/v1/user/enrollment/list/{‌{userId}‌}?orgDetails=name,status&fields=name,someUnsupportedField.   Here we  already have  batch start date , end date and status is standard 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 batchData Map with the standard supported batchdata fields.
  4. Standard batchdata 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 batchdata fields.
  6. Add the other requested data in the 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.

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.Algorithm same as Approach 1

Responses

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

...