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=20v1/search
Methods: GETPOST
---
Internal work flow Request body:

{
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 that based on unique courseList it will fetch complete data and merge count in new response.


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

--- Internal work flow "status":["0","1"],
  When user call this api , it will do course batch search under ES and all  "enrollmentType":"open"
            },
            "offset":0,
            "limit":20
       }
}unique courseIds. After getting list of unique courseIds , it will make call to Content search api by passing all those courseIds and Content search response will be provided to caller.

Internal Api call
URI: /content/v1/search
Method: POST
Request body:
{"request":{"filters":{"identifier": ["list of courseId"]},"sort_by":{"createdOn":"desc"}}}



----
Response:
{
    "id": "api.course.batch.countsearch",
    "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": [
                    {
   
                "identifierownershipType": "",[
                    "createdFor":
 [               ],
         "",       "subject": "Science",
                "channel":  "0124511325012951040",
                  ]"downloadUrl": "https://sunbirdstaging.blob.core.windows.net/sunbird-content-staging/ecar_files/do_2126299478299033601672/course-rf-09112018-2_1541742032021_do_2126299478299033601672_1.0_spine.ecar",
                    "courseAdditionalInfoorganisation": [
{                    "SunbirdQA 1",
    "courseName": "SUBU_01",               "Sunbird QA Tenant"
       "leafNodesCount": "3",        ],
                "descriptionlanguage": "Why?", [
                    "English"
     "courseLogoUrl": "https://sunbirdstaging.blob.core.windows.net/sunbird-content-staging/content/{}/artifact/images-1_1532061239427.thumb.jpg",           ],
                "tocUrlmimeType": "https:application//sunbirdstaging.blob.core.windows.net/sunbird-content-staging/content/{}/artifact/{}toc.jsonvnd.ekstep.content-collection",
                "variants": {
      "status": "Live"                 "spine": {
   },                     "endDateecarUrl": "2018-12-31"https://sunbirdstaging.blob.core.windows.net/sunbird-content-staging/ecar_files/do_2126299478299033601672/course-rf-09112018-2_1541742032021_do_2126299478299033601672_1.0_spine.ecar",
                    "description": "nieowhoifheoiw",   "size": 167578
                "participant": {   }
                },
    "userId": true                     },
   "objectType": "Content",
                "countIncrementStatusgradeLevel": false,[
                    "createdDate": "2018-11-21 04:47:18:306+0000",Class 9"
                    "createdBy": ""],
                    "courseCreator": "",
   "appIcon": "https://sunbirdstaging.blob.core.windows.net/sunbird-content-staging/content/do_2126299478299033601672/artifact/1193-600x337_1524060806727.thumb.jpg",
                "hashTagIdchildren": "0126384233410641921"[],
                    "mentorsappId": [],
                    "countDecrementStatus": false,
  "staging.sunbird.app",
                 "namecontentEncoding": "My batchgzip",
   
                "idmimeTypesCount": "0126384233410641921",
   {\"application/vnd.ekstep.html-archive\":1,\"video/webm\":1,\"application/vnd.ekstep.content-collection\":1,\"video/mp4\":1}",
                "enrollmentTypecontentType": "openCourse",
 
                  "courseIdidentifier": "do_2126384162272460801572126299478299033601672",
   
                "startDatelastUpdatedBy": "2018-11-21",
   bf622d07-ca95-4cc1-9a49-a4518925a4d8",
                "statusaudience": 1,[
                    "openBatchCountLearner":2
                }],
                { "visibility": "Default",
                    ........"toc_url": "https://sunbirdstaging.blob.core.windows.net/sunbird-content-staging/content/do_2126299478299033601672/artifact/do_2126299478299033601672toc.json",
                    "courseId": "do_2126299478299033601672",
"contentTypesCount": "{\"CourseUnit\":1,\"Resource\":3}",
                   "openBatchCountconsumerId":2
  "dc56def7-ecfd-4001-ab2f-d98251ed40e2",
                "childNodes": [
                    "do_2123236738896609281243",
        }            "do_2123717816919900161187",
]         }     }
}

...

  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.

...

      "do_2126299480633671681673",
                    "do_2123717841558814721189"
                ],
                "mediaType": "content",
                "osId": "org.ekstep.quiz.app",
                "graph_id": "domain",
                "nodeType": "DATA_NODE",
                "lastPublishedBy": "9ac4ea92-fea7-45e6-93f3-02aa3172ea58",
                "prevState": "Review",
                "size": 167578,
                "lastPublishedOn": "2018-11-09T05:40:31.997+0000",
                "IL_FUNC_OBJECT_TYPE": "Content",
                "name": "Course RF 09112018 2",
                "status": "Live",
                "code": "org.sunbird.ZwEKh2",
                "description": "Enter description for Course",
                "medium": "Hindi",
                "idealScreenSize": "normal",
                "posterImage": "https://ekstep-public-qa.s3-ap-south-1.amazonaws.com/content/do_21248510612742144014185/artifact/1193-600x337_1524060806727.jpg",
                "createdOn": "2018-11-09T05:34:38.454+0000",
                "contentDisposition": "inline",
                "lastUpdatedOn": "2018-11-09T05:40:31.194+0000",
                "SYS_INTERNAL_LAST_UPDATED_ON": "2018-11-09T08:00:00.413+0000",
                "owner": "Sunbird QA Tenant",
                "creator": "JP Mentor ORg1 user",
                "createdFor": [
                    "012451141730410496558",
                    "0124511325012951040"
                ],
                "IL_SYS_NODE_TYPE": "DATA_NODE",
                "os": [
                    "All"
                ],
                "c_Sunbird_Staging_open_batch_count": 1,
                "pkgVersion": 1,
                "versionKey": "1541742031194",
                "idealScreenDensity": "hdpi",
                "framework": "rj_k-12_1",
                "s3Key": "ecar_files/do_2126299478299033601672/course-rf-09112018-2_1541742032021_do_2126299478299033601672_1.0_spine.ecar",
                "lastSubmittedOn": "2018-11-09T05:39:35.246+0000",
                "createdBy": "bf622d07-ca95-4cc1-9a49-a4518925a4d8",
                "compatibilityLevel": 4,
                "leafNodesCount": 3,
                "IL_UNIQUE_ID": "do_2126299478299033601672",
                "ownedBy": "0124511325012951040",
                "board": "State (Rajasthan)",
                "resourceType": "Course",
                "node_id": 430981
            } ,
            {} 
           ]
        }
    }
}


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.




** Search open batch based on filter will have issues.

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 4:

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

...