From e4c11905c49abb3222dd8891deaa365cb3f1260c Mon Sep 17 00:00:00 2001 From: sdcb Date: Thu, 5 Dec 2024 18:50:43 +0800 Subject: [PATCH] system/default prompt to front --- src/BE/Controllers/Chats/Prompts/PromptsController.cs | 10 +++++++--- src/scripts/20241129-file.sql | 9 ++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/BE/Controllers/Chats/Prompts/PromptsController.cs b/src/BE/Controllers/Chats/Prompts/PromptsController.cs index db134746..65471883 100644 --- a/src/BE/Controllers/Chats/Prompts/PromptsController.cs +++ b/src/BE/Controllers/Chats/Prompts/PromptsController.cs @@ -16,7 +16,9 @@ public async Task> GetPrompts(CancellationToken cancel { PromptDto[] prompts = await db.Prompts .Where(x => x.CreateUserId == currentUser.Id || currentUser.IsAdmin && x.IsSystem) - .OrderBy(x => x.UpdatedAt) + .OrderBy(x => x.IsSystem) + .ThenBy(x => x.IsDefault) + .ThenBy(x => x.UpdatedAt) .Select(x => new PromptDto() { Content = x.Content, @@ -36,7 +38,9 @@ public async Task> GetBriefPrompts(CancellationTo { BriefPromptDto[] prompts = await db.Prompts .Where(x => x.CreateUserId == currentUser.Id || currentUser.IsAdmin && x.IsSystem) - .OrderBy(x => x.UpdatedAt) + .OrderBy(x => x.IsSystem) + .ThenBy(x => x.IsDefault) + .ThenBy(x => x.UpdatedAt) .Select(x => new BriefPromptDto() { Id = x.Id, @@ -78,7 +82,7 @@ public async Task> GetDefaultPrompt(CancellationToken ca .FirstOrDefaultAsync(cancellationToken); Prompt? systemDefault = await db.Prompts .OrderByDescending(x => x.UpdatedAt) - .Where(x => x.IsDefault && x.IsSystem) + .Where(x => x.IsSystem) .FirstOrDefaultAsync(cancellationToken); Prompt? consolidated = userDefault ?? systemDefault; diff --git a/src/scripts/20241129-file.sql b/src/scripts/20241129-file.sql index c775b608..ffb944e2 100644 --- a/src/scripts/20241129-file.sql +++ b/src/scripts/20241129-file.sql @@ -1350,4 +1350,11 @@ FROM [dbo].[MessageContent] WHERE ContentTypeId = 2; ALTER TABLE [dbo].[MessageContent] -DROP COLUMN [Content]; \ No newline at end of file +DROP COLUMN [Content]; + + +-- 20241205 +EXECUTE sp_rename N'dbo.MessageContentUTF16', N'MessageContentText', 'OBJECT'; +INSERT INTO MessageContentText(Id, Content) +SELECT Id, Content FROM MessageContentUTF8; +DROP TABLE MessageContentUTF8; \ No newline at end of file