return first game if filtering by score didn't work out

This commit is contained in:
13xforever 2019-03-07 00:12:17 +05:00
parent cda055882a
commit 993cc54c98
2 changed files with 14 additions and 8 deletions

View File

@ -342,6 +342,10 @@ namespace CompatBot.Commands
[Command("download"), Cooldown(1, 10, CooldownBucketType.Channel)]
[Description("Find games to download")]
public Task Download(CommandContext ctx, [RemainingText] string game)
=> Psn.SearchForGame(ctx, game);
{
if (game?.ToUpperInvariant() == "RPCS3")
return CompatList.UpdatesCheck.CheckForRpcs3Updates(ctx.Client, ctx.Channel);
return Psn.SearchForGame(ctx, game);
}
}
}

View File

@ -132,14 +132,16 @@ namespace CompatBot.Commands
if (included == null)
return null;
return (
from i in included
var games = (from i in included
where (i.Type == "game" || i.Type == "legacy-sku") && (i.Attributes.TopCategory != "demo" && i.Attributes.GameContentType != "Demo")
let m = new {score = search.GetFuzzyCoefficientCached(i.Attributes.Name), item = i}
where m.score > 0.3 || (i.Attributes.Name?.StartsWith(search, StringComparison.InvariantCultureIgnoreCase) ?? false)
orderby m.score descending
select m.item
).FirstOrDefault();
select i).ToList();
return (from i in games
let m = new {score = search.GetFuzzyCoefficientCached(i.Attributes.Name), item = i}
where m.score > 0.3 || (i.Attributes.Name?.StartsWith(search, StringComparison.InvariantCultureIgnoreCase) ?? false)
orderby m.score descending
select m.item
).FirstOrDefault() ??
games.FirstOrDefault();
}
private static async Task TryDeleteThumbnailCache(CommandContext ctx, List<(string contentId, string link)> linksToRemove)