This commit is contained in:
@@ -75,7 +75,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// </summary>
|
||||
/// <returns>Event log for user</returns>
|
||||
[HttpGet("UserLog")]
|
||||
public async Task<IActionResult> GetUserLog([FromQuery] EventLogOptions opt)
|
||||
public async Task<IActionResult> GetUserLog([FromQuery] UserEventLogOptions opt)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -112,12 +112,21 @@ namespace AyaNova.Api.Controllers
|
||||
[FromQuery]
|
||||
public long AyId { get; set; }
|
||||
[FromQuery]
|
||||
public DateTime? StartDate { get; set; }
|
||||
public int? Offset { get; set; }
|
||||
[FromQuery]
|
||||
public DateTime? EndDate { get; set; }
|
||||
public int? Limit { get; set; }
|
||||
}
|
||||
|
||||
public sealed class UserEventLogOptions
|
||||
{
|
||||
|
||||
[FromQuery]
|
||||
public long AyId { get; set; }
|
||||
[FromQuery]
|
||||
public int? Offset { get; set; }
|
||||
[FromQuery]
|
||||
public int? Limit { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ObjectEventLogItem
|
||||
{
|
||||
|
||||
@@ -52,13 +52,9 @@ namespace AyaNova.Biz
|
||||
var q = ct.Event.Select(m => m).AsNoTracking();
|
||||
|
||||
q = q.Where(m => m.AyId == opt.AyId);
|
||||
|
||||
if (opt.StartDate != null)
|
||||
q = q.Where(m => m.Created > opt.StartDate);
|
||||
|
||||
if (opt.EndDate != null)
|
||||
q = q.Where(m => m.Created < opt.EndDate);
|
||||
|
||||
q = q.OrderBy(m => m.Created);
|
||||
var limit = opt.Limit ?? 100;
|
||||
var offset = opt.Offset ?? 0;
|
||||
q = q.OrderBy(m => m.Created);
|
||||
|
||||
//Execute the query
|
||||
@@ -82,20 +78,16 @@ namespace AyaNova.Biz
|
||||
/// Get the event log for a specified User
|
||||
/// Presentation is the client's responsibility (localization internationalization etc)
|
||||
/// </summary>
|
||||
internal static async Task<AyaNova.Api.Controllers.EventLogController.UserEventLogItem[]> GetLogForUserAsync(AyaNova.Api.Controllers.EventLogController.EventLogOptions opt, AyContext ct)
|
||||
internal static async Task<AyaNova.Api.Controllers.EventLogController.UserEventLogItem[]> GetLogForUserAsync(AyaNova.Api.Controllers.EventLogController.UserEventLogOptions opt, AyContext ct)
|
||||
{
|
||||
//Set up the query
|
||||
var q = ct.Event.Select(m => m);
|
||||
|
||||
q = q.Where(m => m.UserId == opt.AyId);
|
||||
|
||||
if (opt.StartDate != null)
|
||||
q = q.Where(m => m.Created > opt.StartDate);
|
||||
|
||||
if (opt.EndDate != null)
|
||||
q = q.Where(m => m.Created < opt.EndDate);
|
||||
|
||||
var limit = opt.Limit ?? 100;
|
||||
var offset = opt.Offset ?? 0;
|
||||
q = q.OrderBy(m => m.Created);
|
||||
q.Skip(offset).Take(limit);
|
||||
|
||||
//Execute the query
|
||||
var EventItems = await q.ToArrayAsync();
|
||||
|
||||
Reference in New Issue
Block a user