Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-16468

CLONE [5.0.N] - skipCount does not appear to work for Workflow tasks REST api

    Details

      Description

      skipCount argument for REST call to

      /alfresco/api/-default-/public/workflow/versions/1/tasks
      

      does not appear to work correctly. From reading the [http://docs.alfresco.com/4.2/pra/1/concepts/pra-pagination.html|Pagination] help, skipCount should skip the first n results from the totalItems amount and return the next page (or up to maxItems). The problem appears to be that skipCount is always referring to the original page results, not to the totalItems.

      For example:
      Say, we have 1050 tasks assigned to a group and we are querying using a few clauses, thus slowing the query down and forcing pagination:

      http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/tasks?skipCount=0&maxItems=2000&where=(candidateUser = 'admin' AND status = 'active' AND includeTaskVariables = 'true' AND includeProcessVariables = 'true')

      we get:
      gets:
      {"list":{"pagination":

      {"count":625,"hasMoreItems":true,"totalItems":1050,"skipCount":0,"maxItems":2000}

      From what I understand of the docs, setting skipCount to 625 in a follow-up query would get either all of the remaining results or the next page (depending on the speed of the query). However it appears that skipCount currently refers to the totalItems, therefore changing the skipCount to 625 in this case returns zero results, i.e.

      {"list":{"pagination":

      {"count":0,"hasMoreItems":true,"totalItems":1050,"skipCount":625,"maxItems":2000}

      ,"entries":[]}}

      Steps to reproduce

      1. Create ~1050 workflow tasks
      1a. Upload a document to the repository and get it's nodeRef
      1b. Using javascript-console, get that document and create a workflow package with it and then create and start 1050 workflows assigned to the admin group, i.e.

      var document = search.findNode("workspace://SpacesStore/788e5602-0d99-445b-aaaf-af166fd3ed1a"); // <-- place your document's nodeRef here
      
      for (var i = 0; i < 1050; i++)  {
      
      var workflowPackage = workflow.createPackage();
      workflowPackage.addNode(document);
      
      var wfdef = workflow.getDefinitionByName("activiti$activitiReviewPooled");
        
      var wfparams = new Object();
      wfparams["bpm:workflowDescription"] = "Start workflow - ";
      wfparams["bpm:groupAssignee"] = people.getGroup("GROUP_ALFRESCO_ADMINISTRATORS");
      
      wfdef.startWorkflow(workflowPackage,wfparams);
      }

      2. Once that completes run the following REST call from a browser:

      http://localhost:8080/alfresco/api/-default-/public/workflow/versions/1/tasks?skipCount=0&maxItems=2000&where=%28candidateUser%20%3D%20%27admin%27%20AND%20status%20%3D%20%27active%27%20AND%20includeTaskVariables%20%3D%20%27true%27%20AND%20includeProcessVariables%20%3D%20%27true%27%29%20

      At this point, it should page the first set of results, in my environment, I get 625 returned, i.e.
      {"list":{"pagination":

      {"count":625,"hasMoreItems":true,"totalItems":1050,"skipCount":0,"maxItems":2000}

      3. Change the query's skipCount to 625 for example (or whatever the total of the returned number was previously) and send the call again.

      Expected behaviour
      Call should skip the first paged set and return the next page (or the rest of the results)

      Actual behaviour
      The first page is returned again minus the skipCount.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                closedbugs Closed Bugs
                Reporter:
                astrachan Alex Strachan
              • Votes:
                0 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 20 minutes
                  4h 20m