2
0

Remove sortNumber-field from Chapter

API: Change Tasks/Progress chapterSortNumber to ChapterNumber
This commit is contained in:
glax 2023-06-27 23:06:37 +02:00
parent b3e1d39d0f
commit 25a6ceff10
3 changed files with 6 additions and 13 deletions

View File

@ -323,7 +323,7 @@ public class RequestHandler
variables.TryGetValue("taskType", out string? taskType2);
variables.TryGetValue("connectorName", out string? connectorName4);
variables.TryGetValue("publicationId", out string? publicationId);
variables.TryGetValue("chapterSortNumber", out string? chapterSortNumber);
variables.TryGetValue("chapterNumber", out string? chapterNumber);
if (taskType2 is null || connectorName4 is null || publicationId is null)
return null;
Connector? connector =
@ -337,10 +337,10 @@ public class RequestHandler
if (pTask is TrangaTask.Task.MonitorPublication)
{
task = _taskManager.GetTasksMatching(pTask, connectorName: connectorName4, internalId: publicationId).FirstOrDefault();
}else if (pTask is TrangaTask.Task.DownloadChapter && chapterSortNumber is not null)
}else if (pTask is TrangaTask.Task.DownloadChapter && chapterNumber is not null)
{
task = _taskManager.GetTasksMatching(pTask, connectorName: connectorName4, internalId: publicationId,
chapterSortNumber: chapterSortNumber).FirstOrDefault();
chapterNumber: chapterNumber).FirstOrDefault();
}
if (task is null)
return null;

View File

@ -14,7 +14,6 @@ public struct Chapter
public string? chapterNumber { get; }
public string url { get; }
public string fileName { get; }
public string sortNumber { get; }
private static readonly Regex LegalCharacters = new Regex(@"([A-z]*[0-9]* *\.*-*,*\]*\[*'*\'*\)*\(*~*!*)*");
public Chapter(string? name, string? volumeNumber, string? chapterNumber, string url)
@ -23,12 +22,6 @@ public struct Chapter
this.volumeNumber = volumeNumber;
this.chapterNumber = chapterNumber;
this.url = url;
NumberFormatInfo nfi = new NumberFormatInfo()
{
NumberDecimalSeparator = "."
};
sortNumber = decimal.Round(Convert.ToDecimal(this.volumeNumber ?? "1") * Convert.ToDecimal(this.chapterNumber, nfi), 1)
.ToString(nfi);
string chapterName = string.Concat(LegalCharacters.Matches(name ?? ""));
string volStr = this.volumeNumber is not null ? $"Vol.{this.volumeNumber} " : "";

View File

@ -179,7 +179,7 @@ public class TaskManager
return Array.Empty<TrangaTask>();
}
public IEnumerable<TrangaTask> GetTasksMatching(TrangaTask.Task taskType, string? connectorName = null, string? searchString = null, string? internalId = null, string? chapterSortNumber = null)
public IEnumerable<TrangaTask> GetTasksMatching(TrangaTask.Task taskType, string? connectorName = null, string? searchString = null, string? internalId = null, string? chapterNumber = null)
{
switch (taskType)
{
@ -215,12 +215,12 @@ public class TaskManager
mTask is DownloadChapterTask dct && dct.connectorName == connectorName &&
dct.ToString().Contains(searchString, StringComparison.InvariantCultureIgnoreCase));
}
else if (internalId is not null && chapterSortNumber is not null)
else if (internalId is not null && chapterNumber is not null)
{
return _allTasks.Where(mTask =>
mTask is DownloadChapterTask dct && dct.connectorName == connectorName &&
dct.publication.internalId == internalId &&
dct.chapter.sortNumber == chapterSortNumber);
dct.chapter.chapterNumber == chapterNumber);
}
else
return _allTasks.Where(mTask =>