2020-11-06 15:38:57 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using osu.Game.Online.API.Requests;
|
2021-11-04 17:02:44 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-11-06 15:38:57 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
2021-12-21 17:33:28 +08:00
|
|
|
public partial class UserLookupCache : OnlineLookupCache<int, APIUser, GetUsersRequest>
|
2020-11-06 15:38:57 +08:00
|
|
|
{
|
2020-12-28 19:05:48 +08:00
|
|
|
/// <summary>
|
2021-11-04 17:02:44 +08:00
|
|
|
/// Perform an API lookup on the specified user, populating a <see cref="APIUser"/> model.
|
2020-12-28 19:05:48 +08:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="userId">The user to lookup.</param>
|
|
|
|
/// <param name="token">An optional cancellation token.</param>
|
|
|
|
/// <returns>The populated user, or null if the user does not exist or the request could not be satisfied.</returns>
|
2023-06-09 17:24:38 +08:00
|
|
|
public Task<APIUser?> GetUserAsync(int userId, CancellationToken token = default) => LookupAsync(userId, token);
|
2020-11-06 15:38:57 +08:00
|
|
|
|
2021-07-05 18:56:16 +08:00
|
|
|
/// <summary>
|
2021-11-04 17:02:44 +08:00
|
|
|
/// Perform an API lookup on the specified users, populating a <see cref="APIUser"/> model.
|
2021-07-05 18:56:16 +08:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="userIds">The users to lookup.</param>
|
|
|
|
/// <param name="token">An optional cancellation token.</param>
|
2021-07-05 20:30:24 +08:00
|
|
|
/// <returns>The populated users. May include null results for failed retrievals.</returns>
|
2023-06-09 17:24:38 +08:00
|
|
|
public Task<APIUser?[]> GetUsersAsync(int[] userIds, CancellationToken token = default) => LookupAsync(userIds, token);
|
2020-11-17 09:57:11 +08:00
|
|
|
|
2021-12-21 17:33:28 +08:00
|
|
|
protected override GetUsersRequest CreateRequest(IEnumerable<int> ids) => new GetUsersRequest(ids.ToArray());
|
2020-11-16 19:35:22 +08:00
|
|
|
|
2023-06-09 17:24:38 +08:00
|
|
|
protected override IEnumerable<APIUser>? RetrieveResults(GetUsersRequest request) => request.Response?.Users;
|
2020-11-06 15:38:57 +08:00
|
|
|
}
|
|
|
|
}
|