API: Updated /Tasks/GetProgress to return progress of specific task (by sortNumber)
This commit is contained in:
parent
a3a96b6b55
commit
6485b8744f
@ -144,14 +144,24 @@ app.MapGet("/Tasks/Get", (string taskType, string? connectorName, string? search
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.MapGet("/Tasks/GetProgress", (string taskType, string? connectorName, string? publicationId) =>
|
app.MapGet("/Tasks/GetProgress", (string taskType, string connectorName, string publicationId, string? chapterSortNumber) =>
|
||||||
{
|
{
|
||||||
|
Connector? connector =
|
||||||
|
taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName).Value;
|
||||||
|
if (connector is null)
|
||||||
|
return -1f;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
TrangaTask? task = null;
|
||||||
TrangaTask.Task pTask = Enum.Parse<TrangaTask.Task>(taskType);
|
TrangaTask.Task pTask = Enum.Parse<TrangaTask.Task>(taskType);
|
||||||
TrangaTask? task = taskManager
|
if (pTask is TrangaTask.Task.DownloadNewChapters)
|
||||||
.GetTasksMatching(pTask, connectorName: connectorName, internalId: publicationId)?.First();
|
{
|
||||||
|
task = taskManager.GetTasksMatching(pTask, connectorName: connectorName, internalId: publicationId).FirstOrDefault();
|
||||||
|
}else if (pTask is TrangaTask.Task.DownloadChapter && chapterSortNumber is not null)
|
||||||
|
{
|
||||||
|
task = taskManager.GetTasksMatching(pTask, connectorName: connectorName, internalId: publicationId,
|
||||||
|
chapterSortNumber: chapterSortNumber).FirstOrDefault();
|
||||||
|
}
|
||||||
if (task is null)
|
if (task is null)
|
||||||
return -1f;
|
return -1f;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user