Skip to content

Commit

Permalink
Code formatting pass
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Oct 31, 2024
1 parent 1866756 commit 223a2cd
Showing 1 changed file with 40 additions and 50 deletions.
90 changes: 40 additions & 50 deletions osu.Server.Queues.ScoreStatisticsProcessor/Stores/BeatmapStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,44 +126,37 @@ public async Task<DifficultyAttributes> GetDifficultyAttributesAsync(Beatmap bea
return calculator.Calculate(mods);
}

LegacyMods legacyModValue = getLegacyModsForAttributeLookup(beatmap, ruleset, mods);
DifficultyAttributeKey key = new DifficultyAttributeKey(beatmap.beatmap_id, (uint)ruleset.RulesetInfo.OnlineID, (uint)getLegacyModsForAttributeLookup(beatmap, ruleset, mods));

DifficultyAttributeKey key = new DifficultyAttributeKey(beatmap.beatmap_id, (uint)ruleset.RulesetInfo.OnlineID, (uint)legacyModValue);
return (await attributeMemoryCache.GetOrCreateAsync(key, async cacheEntry =>
{
try
{
BeatmapDifficultyAttribute[] dbAttributes = (await connection.QueryAsync<BeatmapDifficultyAttribute>(
"SELECT * FROM osu_beatmap_difficulty_attribs WHERE `beatmap_id` = @BeatmapId AND `mode` = @RulesetId AND `mods` = @ModValue", new
{
key.BeatmapId,
key.RulesetId,
key.ModValue
}, transaction: transaction)).ToArray();

// approximated
cacheEntry.SetSize(difficulty_attribute_size + beatmap_difficulty_attribute_size * dbAttributes.Length);
cacheEntry.SetSlidingExpiration(memory_cache_sliding_expiration);

return (await attributeMemoryCache.GetOrCreateAsync(
key,
async cacheEntry =>
DifficultyAttributes attributes = LegacyRulesetHelper.CreateDifficultyAttributes(ruleset.RulesetInfo.OnlineID);
attributes.FromDatabaseAttributes(dbAttributes.ToDictionary(a => (int)a.attrib_id, a => (double)a.value), beatmap);
return attributes;
}
catch (Exception ex)
{
try
{
DifficultyAttributes attribs = LegacyRulesetHelper.CreateDifficultyAttributes(ruleset.RulesetInfo.OnlineID);

BeatmapDifficultyAttribute[] dbAttribs = (await connection.QueryAsync<BeatmapDifficultyAttribute>(
"SELECT * FROM osu_beatmap_difficulty_attribs WHERE `beatmap_id` = @BeatmapId AND `mode` = @RulesetId AND `mods` = @ModValue", new
{
key.BeatmapId,
key.RulesetId,
key.ModValue
}, transaction: transaction)).ToArray();

attribs.FromDatabaseAttributes(dbAttribs.ToDictionary(a => (int)a.attrib_id, a => (double)a.value), beatmap);

cacheEntry.SetSlidingExpiration(memory_cache_sliding_expiration);

// approximated
cacheEntry.SetSize(difficulty_attribute_size + beatmap_difficulty_attribute_size * dbAttribs.Length);

return attribs;
}
catch (Exception ex)
{
throw new DifficultyAttributesMissingException(key, ex);
}
finally
{
Interlocked.Increment(ref attribCacheMiss);
}
}))!;
throw new DifficultyAttributesMissingException(key, ex);
}
finally
{
Interlocked.Increment(ref attribCacheMiss);
}
}))!;
}

/// <remarks>
Expand Down Expand Up @@ -191,23 +184,20 @@ private static LegacyMods getLegacyModsForAttributeLookup(Beatmap beatmap, Rules
/// <param name="connection">The <see cref="MySqlConnection"/>.</param>
/// <param name="transaction">An existing transaction.</param>
/// <returns>The retrieved beatmap, or <c>null</c> if not existing.</returns>
public Task<Beatmap?> GetBeatmapAsync(uint beatmapId, MySqlConnection connection, MySqlTransaction? transaction = null)
{
return beatmapMemoryCache.GetOrCreateAsync(
beatmapId,
cacheEntry =>
{
Interlocked.Increment(ref beatmapCacheMiss);
public Task<Beatmap?> GetBeatmapAsync(uint beatmapId, MySqlConnection connection, MySqlTransaction? transaction = null) => beatmapMemoryCache.GetOrCreateAsync(
beatmapId,
cacheEntry =>
{
Interlocked.Increment(ref beatmapCacheMiss);

cacheEntry.SetSlidingExpiration(memory_cache_sliding_expiration);
cacheEntry.SetSize(beatmap_size);
cacheEntry.SetSlidingExpiration(memory_cache_sliding_expiration);
cacheEntry.SetSize(beatmap_size);

return connection.QuerySingleOrDefaultAsync<Beatmap?>("SELECT * FROM osu_beatmaps WHERE `beatmap_id` = @BeatmapId", new
{
BeatmapId = beatmapId
}, transaction: transaction);
});
}
return connection.QuerySingleOrDefaultAsync<Beatmap?>("SELECT * FROM osu_beatmaps WHERE `beatmap_id` = @BeatmapId", new
{
BeatmapId = beatmapId
}, transaction: transaction);
});

/// <summary>
/// Whether performance points may be awarded for the given beatmap and ruleset combination.
Expand Down

0 comments on commit 223a2cd

Please sign in to comment.