Skip to content

Commit

Permalink
Update from reviewer (verbal) comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Dec 5, 2024
1 parent 1e937f5 commit 5aae42c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ await context.RespondAsync(
Files = corpus
.Files.Select(f => new CorpusFileResult
{
TextId = f.TextId!,
File = Map(corpusDataFilesDict[f.FileRef]!)
TextId = f.TextId ?? corpusDataFilesDict[f.FileRef].Name,
File = Map(corpusDataFilesDict[f.FileRef])
})
.ToList()
}
Expand Down
4 changes: 2 additions & 2 deletions src/Serval/src/Serval.DataFiles/Services/CorpusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ await _mediator.Publish(
Files = corpus
.Files.Select(f => new CorpusFileResult
{
TextId = f.TextId!,
File = Map(corpusDataFilesDict[f.FileRef]!)
TextId = f.TextId ?? corpusDataFilesDict[f.FileRef].Name,
File = Map(corpusDataFilesDict[f.FileRef])
})
.ToList()
},
Expand Down
9 changes: 9 additions & 0 deletions src/Serval/src/Serval.Shared/Services/EntityServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ public virtual async Task<T> GetAsync(string id, CancellationToken cancellationT
return entity;
}

public virtual async Task<IEnumerable<T>> GetAllAsync(
IEnumerable<string> ids,
CancellationToken cancellationToken = default
)
{
HashSet<string> idSet = ids.ToHashSet();
return await Entities.GetAllAsync(e => idSet.Contains(e.Id), cancellationToken);
}

public virtual async Task<T> CreateAsync(T entity, CancellationToken cancellationToken = default)
{
await Entities.InsertAsync(entity, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,4 @@ public virtual async Task<IEnumerable<T>> GetAllAsync(string owner, Cancellation
{
return await Entities.GetAllAsync(e => e.Owner == owner, cancellationToken);
}

public virtual async Task<IEnumerable<T>> GetAllAsync(
IEnumerable<string> ids,
CancellationToken cancellationToken = default
)
{
HashSet<string> idSet = ids.ToHashSet();
return await Entities.GetAllAsync(e => idSet.Contains(e.Id), cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private static CorpusFile Map(CorpusFileResult corpusFile)
return new CorpusFile
{
Id = corpusFile.File.DataFileId,
TextId = corpusFile.TextId,
TextId = corpusFile.TextId ?? corpusFile.File.Name,
Filename = corpusFile.File.Filename,
Format = corpusFile.File.Format,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ CancellationToken cancellationToken
Id = f.File.DataFileId,
Filename = f.File.Filename,
Format = f.File.Format,
TextId = f.TextId
TextId = f.TextId ?? f.File.Name
})
.ToList(),
}
Expand Down

0 comments on commit 5aae42c

Please sign in to comment.