Problem statement :
Consumer want to show count of upcoming and ongoing open batches for a course. Since course is stored under learning platform and created batch from course are stored under sunbird-LMS.
There are two different system and they don't know each other apart from validation.
Proposed Solution 1:
As of now Sunbird is running a cron job on daily basis, to update some meta data inside course. This scheduler job will do following actions.
* Select all those batch whose startDate <= today date and countIncrementStatus is false.
* Select all those batch whose endDate >= yesterday date countDecrementStatus is false.
* Now based on above two query and batch type (open or invite-only) , it will update course meta data as follow.
* in case of course going to start now. it will add key as ""c_" + {"sunbird_installation"}+ "_open_batch_count" or c_{"sunbird_installation"}_private_batch_count. with value as int.
* in case of batch end , it will decrements count against same key.
Pros | Cons |
---|---|
As get course has meta data to indicate open batch count per installation, so no need to make any extra api call |
|
2. Data is updated by scheduler job and scheduler job is not 100% guaranteed | |
3. Some time due to content attribute changes , it's not able to update the content, so in that case meta data won't be updated. |
Note : So to support solution 1: we need to take following actions:
Actions |
---|
|
Proposed Solution 2:
User can make another api as batch search api by passing all courseIds and some extra filters.
{"request":{"filters":{ "courseId" : ["do_112634552998936576175","do_112634535631675392173","do_112633845274157056122"],"status":["0","1"],"enrollmentType":"open"}, "sort_by":{"createdDate":"desc"} } }
Pros | Cons |
---|---|
|
|
Proposed Solution 3:
Sunbird will expose a new api to get open batch count for list of courseIds. New api details will be as follows:
URI: v1/course/batch/count Methods: POST Request body 1: { "request": { "filters":{ "courseId":["courseId-1","courseId-2"], "status":["0","1"], "enrollmentType":"open" } } } Request body 2: { "request": { "filters":{ "courseId":["courseId-1","courseId-2"] } } } Request body 3: { "request": { "courseId":["courseId-1","courseId-2"] } } ---- Response: { "id": "api.course.batch.count", "ver": "v1", "ts": "2018-11-20 17:53:00:716+0000", "params": { "resmsgid": null, "msgid": "8e27cbf5-e299-43b0-bca7-8347f7e5abcf", "err": null, "status": "success", "errmsg": null }, "responseCode": "OK", "result": { "response": { "count": 8, "content": [ { "courseId": "do_2126299478299033601672", "openBatchCount":2, "inviteOnlyBatchCount":0 }, { "courseId": "do_2126299478299033601672", "openBatchCount":2, "inviteOnlyBatchCount":0 } ] } } }
Pros | Cons |
---|---|
|
|
Open Questions :
- If one course have 3 open batches and caller already enrolled for one batch then do we need to sent open batch count as 3 or 2 or for him there is no open batch to do enroll.