Properly populate QueryResult

This commit is contained in:
Cody Robibero
2022-01-20 08:46:17 -07:00
parent cd4587b43f
commit a60cb280a3
27 changed files with 209 additions and 297 deletions

View File

@@ -59,17 +59,16 @@ namespace Jellyfin.Server.Implementations.Activity
entries = entries.Where(entry => entry.UserId != Guid.Empty == query.HasUserId.Value );
}
return new QueryResult<ActivityLogEntry>
{
Items = await entries
return new QueryResult<ActivityLogEntry>(
query.Skip,
await entries.CountAsync().ConfigureAwait(false),
await entries
.Skip(query.Skip ?? 0)
.Take(query.Limit ?? 100)
.AsAsyncEnumerable()
.Select(ConvertToOldModel)
.ToListAsync()
.ConfigureAwait(false),
TotalRecordCount = await entries.CountAsync().ConfigureAwait(false)
};
.ConfigureAwait(false));
}
/// <inheritdoc />

View File

@@ -145,12 +145,10 @@ namespace Jellyfin.Server.Implementations.Devices
devices = devices.Take(query.Limit.Value);
}
return new QueryResult<Device>
{
Items = await devices.ToListAsync().ConfigureAwait(false),
StartIndex = query.Skip ?? 0,
TotalRecordCount = count
};
return new QueryResult<Device>(
query.Skip,
count,
await devices.ToListAsync().ConfigureAwait(false));
}
/// <inheritdoc />
@@ -158,12 +156,10 @@ namespace Jellyfin.Server.Implementations.Devices
{
var devices = await GetDevices(query).ConfigureAwait(false);
return new QueryResult<DeviceInfo>
{
Items = devices.Items.Select(device => ToDeviceInfo(device)).ToList(),
StartIndex = devices.StartIndex,
TotalRecordCount = devices.TotalRecordCount
};
return new QueryResult<DeviceInfo>(
devices.StartIndex,
devices.TotalRecordCount,
devices.Items.Select(device => ToDeviceInfo(device)).ToList());
}
/// <inheritdoc />