Versions Compared

Key

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

...

Code Block
languagejs
titlenew api to get course batch count
URI: v1/course/batch/count?offset=0&limit=20
Methods: GET
--- Internal work flow :
  When user call this api , it will internally make course batch search by passing different filters.

 It will internally make two ES call. first call to collect all courseIds with participant list . Based on that response it will keep count of same courseId and remove those courseId for which user is already enrolled.
After thatunique courseIds  and then based on unique courseListthat it will fetchmake completeanother dataEs andcall mergeto count in new responsecollect details.


{
 "request": {
     "filters":{
              "courseId":["list of courseId found in first search"]
              "status":["0","1"],     
              "enrollmentType":"open"
            },
            "offset":0,
            "limit":20
       }
}


----
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": [
                   {
                    "identifier": "",
                    "createdFor": [
                        "",
                        ""
                    ],
                    "courseAdditionalInfo": {
                        "courseName": "SUBU_01",
                        "leafNodesCount": "3",
                        "description": "Why?",
                        "courseLogoUrl": "https://sunbirdstaging.blob.core.windows.net/sunbird-content-staging/content/{}/artifact/images-1_1532061239427.thumb.jpg",
                        "tocUrl": "https://sunbirdstaging.blob.core.windows.net/sunbird-content-staging/content/{}/artifact/{}toc.json",
                        "status": "Live"
                    },
                    "endDate": "2018-12-31",
                    "description": "nieowhoifheoiw",
                    "participant": {
                        "userId": true
                    },
                    "countIncrementStatus": false,
                    "createdDate": "2018-11-21 04:47:18:306+0000",
                    "createdBy": "",
                    "courseCreator": "",
                    "hashTagId": "0126384233410641921",
                    "mentors": [],
                    "countDecrementStatus": false,
                    "name": "My batch",
                    "id": "0126384233410641921",
                    "enrollmentType": "open",
                    "courseId": "do_212638416227246080157",
                    "startDate": "2018-11-21",
                    "status": 1,

                   "openBatchCount":2
                },
                { 
                    ........
                    "courseId": "do_2126299478299033601672",
                    "openBatchCount":2
                   
               }
            ]
        }
    }
}


ProsCons
  1. Easy to manage , later any other changes can be easily incorporated.
  2. Only one api call that will handle complete business logic  
  3. Using request body 2 or 3 will provide flexibility to move complete business logic on server side.
  1.  new api need to be introduce
  2. Some issues with limit and offset. there might be the case one course is used under "N" number of batches , then in another set as well it can come.




Proposed Solution 3:

  Sunbird will define new page section to provide open course list under page api.

 TO achieve this we need to do following modification under page assemble api and get page section .

   * Now section table need to have calling source as well.  which will include (source, indexName, typeName)

  * Assemble page business logic will be modified to make call based on source 

 * local source can have multiple search query with query order.

ProsCons
  1. for consumer only one page assemble api and that will provide complete data
  1. need to modify existing api , More testing required.
  2.  Due to that requirement table structure need to be modified
  3. some data migration alos required with old section.

Proposed Solution 3:

  User can make another api as batch search api  by passing all courseIds and some extra filters.

...