mirror of
https://github.com/C9Glax/tranga.git
synced 2025-05-22 14:13:01 +02:00
SearchController.cs Local-Search endpoint
This commit is contained in:
parent
6125b036bf
commit
100cb06ba0
@ -58,24 +58,18 @@ public class SearchController(PgsqlContext context, ILog Log) : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initiate a search for a Manga on a specific Connector
|
/// Search for a known Manga
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Query"></param>
|
/// <param name="Query"></param>
|
||||||
/// <response code="200"></response>
|
/// <response code="200"></response>
|
||||||
/// <response code="404">MangaConnector with ID not found</response>
|
|
||||||
/// <response code="406">MangaConnector with ID is disabled</response>
|
|
||||||
/// <response code="500">Error during Database Operation</response>
|
|
||||||
[HttpGet("Local/{Query}")]
|
[HttpGet("Local/{Query}")]
|
||||||
[ProducesResponseType<Manga[]>(Status200OK, "application/json")]
|
[ProducesResponseType<Manga[]>(Status200OK, "application/json")]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
|
||||||
[ProducesResponseType(Status406NotAcceptable)]
|
|
||||||
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
|
|
||||||
public IActionResult SearchMangaLocally(string Query)
|
public IActionResult SearchMangaLocally(string Query)
|
||||||
{
|
{
|
||||||
Dictionary<Manga, double> distance = context.Mangas
|
Dictionary<Manga, double> distance = context.Mangas
|
||||||
.ToArray()
|
.ToArray()
|
||||||
.ToDictionary(m => m, m => NeedlemanWunschStringUtil.CalculateSimilarityPercentage(Query, m.Name));
|
.ToDictionary(m => m, m => NeedlemanWunschStringUtil.CalculateSimilarityPercentage(Query, m.Name));
|
||||||
return Ok(distance.Where(kv => kv.Value > 50).ToArray());
|
return Ok(distance.Where(kv => kv.Value > 50).OrderByDescending(kv => kv.Value).Select(kv => kv.Key).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user