diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-05-27 09:13:09 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-05-27 09:13:09 -0500 |
| commit | 1738eeba4bf9942270b6c0c7481c2f6705588ed9 (patch) | |
| tree | 63e7b2b9c4a2c0896f68ec7d9c418ec0577b9585 /src | |
| parent | 3cdd58f0c5d5aaaac4eb4165512eab1b36c1ce3e (diff) | |
| download | slskd-1738eeba4bf9942270b6c0c7481c2f6705588ed9.tar.gz | |
add counts and mappers
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Core/Search/Domain/Search.cs | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/src/slskd/Core/Search/Domain/Search.cs b/src/slskd/Core/Search/Domain/Search.cs index fcb11a04..b16c7e7c 100644 --- a/src/slskd/Core/Search/Domain/Search.cs +++ b/src/slskd/Core/Search/Domain/Search.cs @@ -28,23 +28,67 @@ namespace slskd.Search public Guid Id { get; init; } = Guid.NewGuid(); public DateTime StartedAt { get; init; } = DateTime.UtcNow; - public DateTime? EndedAt { get; set; } + public DateTime? EndedAt { get; init; } + + /// <summary> + /// Gets the total number of files contained within received responses. + /// </summary> + public int FileCount { get; init; } + + /// <summary> + /// Gets the total number of locked files contained within received responses. + /// </summary> + public int LockedFileCount { get; init; } + + /// <summary> + /// Gets the current number of responses received. + /// </summary> + public int ResponseCount { get; init; } /// <summary> /// Gets the text for which to search. /// </summary> - public string SearchText { get; set; } + public string SearchText { get; init; } /// <summary> /// Gets the state of the search. /// </summary> - public SearchStates State { get; set; } + public SearchStates State { get; init; } /// <summary> /// Gets the unique identifier for the search. /// </summary> - public int Token { get; set; } + public int Token { get; init; } + + public ICollection<SearchResponse> Responses { get; init; } = new List<SearchResponse>(); + + public static Search FromSoulseekSearch(Soulseek.Search search) + { + return new Search() + { + FileCount = search.FileCount, + LockedFileCount = search.LockedFileCount, + ResponseCount = search.ResponseCount, + SearchText = search.SearchText, + State = search.State, + Token = search.Token, + }; + } - public ICollection<SearchResponse> Responses { get; set; } = new List<SearchResponse>(); + public Search WithSoulseekSearch(Soulseek.Search search) + { + return new Search() + { + Id = Id, + StartedAt = StartedAt, + EndedAt = EndedAt, + FileCount = search.FileCount, + LockedFileCount = search.LockedFileCount, + ResponseCount = search.ResponseCount, + SearchText = SearchText, + State = search.State, + Token = Token, + }; + } } } |
