Skip to content

Commit

Permalink
Rename interface method to Sort
Browse files Browse the repository at this point in the history
  • Loading branch information
hansonchun-quartech committed Nov 16, 2024
1 parent 34e7f8a commit a378a9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions webapi/Storage/CosmosDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,13 @@ public async Task<IEnumerable<CopilotChatMessage>> QueryEntitiesAsync(
int count
)
{
// Apply predicate
var queryable = this._container.GetItemLinqQueryable<CopilotChatMessage>(true).Where(predicate);

queryable = this.ApplySort(queryable, sortOptions);
// Apply sorting
queryable = this.Sort(queryable, sortOptions);

// Apply pagination
queryable = queryable.Skip(skip);
if (count > 0)
{
Expand All @@ -178,7 +181,7 @@ int count
return results;
}

public IQueryable<CopilotChatMessage> ApplySort(
public IQueryable<CopilotChatMessage> Sort(
IQueryable<CopilotChatMessage> queryable,
IEnumerable<CopilotChatMessageSortOption>? sortOptions
)
Expand Down
4 changes: 2 additions & 2 deletions webapi/Storage/ISortable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ namespace CopilotChat.WebApi.Storage;

public interface ISortable<T, TSortOption>
{
IQueryable<T> ApplySort(IQueryable<T> queryable, IEnumerable<TSortOption> sortOptions);
IQueryable<T> Sort(IQueryable<T> queryable, IEnumerable<TSortOption> sortOptions);
}

public interface ICopilotChatMessageSortable : ISortable<CopilotChatMessage, CopilotChatMessageSortOption>
{
new IQueryable<CopilotChatMessage> ApplySort(
new IQueryable<CopilotChatMessage> Sort(
IQueryable<CopilotChatMessage> queryable,
IEnumerable<CopilotChatMessageSortOption>? sortOptions
);
Expand Down
4 changes: 2 additions & 2 deletions webapi/Storage/VolatileContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int count
var filteredEntities = this._entities.Values.Where(compiledPredicate);

// Apply sorting
var orderedEntities = this.ApplySort(filteredEntities.AsQueryable(), sortOptions);
var orderedEntities = this.Sort(filteredEntities.AsQueryable(), sortOptions);

// Apply pagination
orderedEntities = orderedEntities.Skip(skip);
Expand All @@ -136,7 +136,7 @@ int count
return await Task.FromResult(orderedEntities);
}

public IQueryable<CopilotChatMessage> ApplySort(
public IQueryable<CopilotChatMessage> Sort(
IQueryable<CopilotChatMessage> queryable,
IEnumerable<CopilotChatMessageSortOption>? sortOptions
)
Expand Down

0 comments on commit a378a9c

Please sign in to comment.