U4-9889 - Paged and filter queries for Users on IUserService

Created by Shannon Deminick 10 May 2017, 05:36:55 Updated by Mads Rasmussen 30 May 2017, 09:59:13

Subtask of: U4-8632

This is needed for the new user editor

Comments

Mads Rasmussen 22 May 2017, 09:46:46

@Shandem The endpoint is working fine. We will have to add some additional info for each user to support the UI. I don’t know if this is something we have available but here is the list:

  • avatar (I know this is not made yet)
  • disabled user and user pending an invite
  • Last login date

I get this error if a make a new search after a search has returned nothing:

Error System.DivideByZeroException: Attempted to divide by zero.

Stack trace at Umbraco.Core.Persistence.Database.Page[T](Int64 page, Int64 itemsPerPage, String sql, Object[] args) in \psf\Home\Documents\test\Umbraco-CMS\src\Umbraco.Core\Persistence\PetaPoco.cs:line 821 at Umbraco.Core.Persistence.Database.Page[T](Int64 page, Int64 itemsPerPage, Sql sql) in \psf\Home\Documents\test\Umbraco-CMS\src\Umbraco.Core\Persistence\PetaPoco.cs:line 836 at Umbraco.Core.Persistence.Repositories.UserRepository.GetPagedResultsByQuery(IQuery1 query, Int64 pageIndex, Int32 pageSize, Int64& totalRecords, String orderBy, Direction orderDirection, String[] userGroups, Nullable1 userState, IQuery1 filter) in \\psf\Home\Documents\test\Umbraco-CMS\src\Umbraco.Core\Persistence\Repositories\UserRepository.cs:line 435 at Umbraco.Core.Persistence.Repositories.UserRepository.GetPagedResultsByQuery(IQuery1 query, Int64 pageIndex, Int32 pageSize, Int64& totalRecords, Expression1 orderBy, Direction orderDirection, String[] userGroups, Nullable1 userState, IQuery1 filter) in \\psf\Home\Documents\test\Umbraco-CMS\src\Umbraco.Core\Persistence\Repositories\UserRepository.cs:line 393 at Umbraco.Core.Services.UserService.GetAll(Int64 pageIndex, Int32 pageSize, Int64& totalRecords, String orderBy, Direction orderDirection, Nullable1 userState, String[] userGroups, String filter) in \psf\Home\Documents\test\Umbraco-CMS\src\Umbraco.Core\Services\UserService.cs:line 543 at Umbraco.Web.Editors.UsersController.GetPagedUsers(Int32 pageNumber, Int32 pageSize, String orderBy, Direction orderDirection, String[] userGroups, String filter) in \psf\Home\Documents\test\Umbraco-CMS\src\Umbraco.Web\Editors\UsersController.cs:line 66 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()


Shannon Deminick 22 May 2017, 11:23:22

Just pushed an update:

  • I've added a userState property which can be:
        Active
        Disabled
        LockedOut
        Invited 
  • I've added emailHash which is used to get the gravatar image - this should be done the same way it's being done now. I've also added customAvatar which will be populated by a URL if they have a custom avatar (not quite supported yet)
  • I've added 'lastLoginDate'


Shannon Deminick 22 May 2017, 11:24:07

@madsrasmussen could you post the HTTP request with query strings when you get that error?


Shannon Deminick 22 May 2017, 11:28:45

I've also wired up the GetById endpoint too ... but that has broke stuff :P


Shannon Deminick 23 May 2017, 07:59:22

I've added endpoints and adjusted the user resource for enabling/disabling multiple users, so you need to pass in a query string of multiple Ids.


Shannon Deminick 24 May 2017, 06:20:47

@mads just putting this back in review, if the paging works then you can move to fixed otherwise if there's errors you are getting with paging let me knwo


Mads Rasmussen 30 May 2017, 09:59:06

@Shandem I have wired up the pagination and everything works as expected. I will set this task as fixed.


Priority: Normal

Type: Task

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.7.0

Sprint: Sprint 60

Story Points: 3

Cycle: