Skip to content

Replace API query for score rank #346

Description

@bdach

Query in question being

public static int? GetScoreRankOnBeatmapLeaderboard(SoloScore score)
{
try
{
string? token = retrieveAccessToken();
if (token == null)
return null;
var requestMsg = new HttpRequestMessage(HttpMethod.Get, $"{shared_interop_domain}/api/v2/scores/{score.id}");
requestMsg.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
requestMsg.Headers.Add("x-api-version", "20250804");
var responseMsg = http.Send(requestMsg);
if (!responseMsg.IsSuccessStatusCode || responseMsg.Content.ReadFromJsonAsync<ScoreResponse>().Result is not ScoreResponse scoreResponse)
{
SentrySdk.CaptureMessage($"Failed to retrieve score rank from API: received status code {responseMsg.StatusCode}, content: {responseMsg.Content.ReadAsStringAsync().Result}",
SentryLevel.Warning);
return null;
}
return scoreResponse.rank_global;
}
catch (Exception e)
{
SentrySdk.CaptureException(e, scope => scope.Level = SentryLevel.Warning);
return null;
}
}

and the solution for its replacement probably being

/// If this ever becomes a problem the proposition is to move the ES lookup logic to https://github.com/ppy/osu-global-rank-lookup-cache and have both web and this call into that component.

Also possibly worth adjusting this such that the rank query isn't under the transaction. See also: #341.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions