mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Hand off comparison logic for database query to implementors
Equals overrides are not used in EF queries without running the comaprison locally instead of on the database, so to preserve that the comparison logic is instead implemented on a per manager basis.
This commit is contained in:
@ -145,6 +145,8 @@ namespace osu.Game.Beatmaps
|
|||||||
void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineBeatmapID = null);
|
void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineBeatmapID = null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool CheckLocalAvailability(BeatmapSetInfo model, IQueryable<BeatmapSetInfo> items) => items.Any(b => b.OnlineBeatmapSetID == model.OnlineBeatmapSetID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a beatmap difficulty.
|
/// Delete a beatmap difficulty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -110,7 +110,15 @@ namespace osu.Game.Database
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool IsAvailableLocally(TModel model) => modelStore.ConsumableItems.Any(m => m.Equals(model) && !m.DeletePending);
|
public bool IsAvailableLocally(TModel model) => CheckLocalAvailability(model, modelStore.ConsumableItems.Where(m => !m.DeletePending));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs implementation specific comparisons to determine whether a given model is present in the local store.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">The <see cref="TModel"/> whose existence needs to be checked.</param>
|
||||||
|
/// <param name="items">The usable items present in the store.</param>
|
||||||
|
/// <returns>Whether the <see cref="TModel"/> exists.</returns>
|
||||||
|
protected abstract bool CheckLocalAvailability(TModel model, IQueryable<TModel> items);
|
||||||
|
|
||||||
public ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model) => currentDownloads.Find(r => r.Model.Equals(model));
|
public ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model) => currentDownloads.Find(r => r.Model.Equals(model));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user