commit
3624ec84a1
|
|
@ -71,5 +71,5 @@ public interface IConversationService
|
|||
/// <param name="convLimit">conversation limit</param>
|
||||
/// <param name="preLoad">if pre-loading, then keys are not filter by the search query</param>
|
||||
/// <returns></returns>
|
||||
Task<List<string>> GetConversationSearhKeys(string query, int convlimit = 100, int keyLimit = 10, bool preLoad = false);
|
||||
Task<List<string>> GetConversationStateSearhKeys(string query, int convlimit = 100, int keyLimit = 10, bool preLoad = false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public interface IBotSharpRepository : IHaveServiceProvider
|
|||
=> throw new NotImplementedException();
|
||||
List<string> TruncateConversation(string conversationId, string messageId, bool cleanLog = false)
|
||||
=> throw new NotImplementedException();
|
||||
List<string> GetConversationSearchKeys(int messageLimit = 2, int convlimit = 100)
|
||||
List<string> GetConversationStateSearchKeys(int messageLowerLimit = 2, int convUpperlimit = 100)
|
||||
=> throw new NotImplementedException();
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ public partial class ConversationService : IConversationService
|
|||
_state.Save();
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetConversationSearhKeys(string query, int convlimit = 100, int keyLimit = 10, bool preLoad = false)
|
||||
public async Task<List<string>> GetConversationStateSearhKeys(string query, int convlimit = 100, int keyLimit = 10, bool preLoad = false)
|
||||
{
|
||||
var keys = new List<string>();
|
||||
if (!preLoad && string.IsNullOrWhiteSpace(query))
|
||||
|
|
@ -231,7 +231,7 @@ public partial class ConversationService : IConversationService
|
|||
}
|
||||
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
keys = db.GetConversationSearchKeys(convlimit: convlimit);
|
||||
keys = db.GetConversationStateSearchKeys(convUpperlimit: convlimit);
|
||||
keys = preLoad ? keys : keys.Where(x => x.Contains(query, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
return keys.OrderBy(x => x).Take(keyLimit).ToList();
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -558,7 +558,7 @@ public class ConversationController : ControllerBase
|
|||
public async Task<List<string>> GetConversationStateKeys([FromQuery] string query, [FromQuery] int keyLimit = 10, [FromQuery] bool preLoad = false)
|
||||
{
|
||||
var convService = _services.GetRequiredService<IConversationService>();
|
||||
var keys = await convService.GetConversationSearhKeys(query, keyLimit: keyLimit, preLoad: preLoad);
|
||||
var keys = await convService.GetConversationStateSearhKeys(query, keyLimit: keyLimit, preLoad: preLoad);
|
||||
return keys;
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -611,13 +611,15 @@ public partial class MongoRepository
|
|||
return deletedMessageIds;
|
||||
}
|
||||
|
||||
|
||||
public List<string> GetConversationSearchKeys(int messageLimit = 2, int convlimit = 100)
|
||||
#if !DEBUG
|
||||
[SharpCache(10)]
|
||||
#endif
|
||||
public List<string> GetConversationStateSearchKeys(int messageLowerLimit = 2, int convUpperlimit = 100)
|
||||
{
|
||||
var convFilter = Builders<ConversationDocument>.Filter.Gte(x => x.DialogCount, messageLimit);
|
||||
var convFilter = Builders<ConversationDocument>.Filter.Gte(x => x.DialogCount, messageLowerLimit);
|
||||
var conversations = _dc.Conversations.Find(convFilter)
|
||||
.SortByDescending(x => x.UpdatedTime)
|
||||
.Limit(convlimit)
|
||||
.Limit(convUpperlimit)
|
||||
.ToList();
|
||||
|
||||
if (conversations.IsNullOrEmpty()) return [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue