From 6c5f7c8b5c2257f2a8b622aa9c2ab2de4d910b8e Mon Sep 17 00:00:00 2001 From: Demis Bellot Date: Thu, 30 May 2024 19:09:19 +0800 Subject: [PATCH] Organize commands under tags --- .../CreateAnswerCommentTaskCommand.cs | 1 + .../AiServer/CreateAnswerTasksCommand.cs | 1 + .../AiServer/CreateRankAnswerTaskCommand.cs | 1 + .../App/AnswerAddedToPostCommand.cs | 1 + .../App/AppDbPeriodicTasksCommand.cs | 1 + .../App/CreateAnswerCommand.cs | 1 + .../App/CreateCommentVoteCommand.cs | 1 + .../App/CreateFlagCommand.cs | 1 + .../App/CreateNotificationCommand.cs | 1 + .../App/CreatePostCommand.cs | 1 + .../App/CreatePostVoteCommand.cs | 1 + .../App/DeleteAnswersCommand.cs | 1 + .../App/DeleteCommentCommand.cs | 1 + .../App/DeletePostsCommand.cs | 1 + .../App/ImportQuestionCommand.cs | 1 + .../App/MarkAsReadCommand.cs | 1 + .../App/MarkPostAsReadCommand.cs | 1 + .../App/NewCommentCommand.cs | 1 + .../App/PostSubscriptionsCommand.cs | 1 + .../App/SaveGradeResultCommand.cs | 1 + .../App/TagSubscriptionsCommand.cs | 1 + .../App/UpdatePostCommand.cs | 1 + .../App/UpdateReputationsCommand.cs | 1 + .../CreatorKit/SendMailRunCommand.cs | 1 + .../CreatorKit/SendMessagesCommand.cs | 2 + MyApp.ServiceInterface/Data/Tasks.cs | 1 + .../{App => Jobs}/CompletePostJobsCommand.cs | 17 ++++---- .../{App => Jobs}/CreatePostJobsCommand.cs | 5 ++- .../{App => Jobs}/FailJobCommand.cs | 7 ++-- .../{App => Jobs}/StartJobCommand.cs | 7 ++-- .../Renderers/RegenerateMetaCommand.cs | 1 + MyApp.ServiceInterface/Tags.cs | 13 ++++++ MyApp.Tests/Top1KQuestionTasks.cs | 41 +++++++++++++++++++ MyApp/Configure.Renderer.cs | 2 + 34 files changed, 104 insertions(+), 16 deletions(-) rename MyApp.ServiceInterface/{App => Jobs}/CompletePostJobsCommand.cs (77%) rename MyApp.ServiceInterface/{App => Jobs}/CreatePostJobsCommand.cs (87%) rename MyApp.ServiceInterface/{App => Jobs}/FailJobCommand.cs (94%) rename MyApp.ServiceInterface/{App => Jobs}/StartJobCommand.cs (89%) create mode 100644 MyApp.ServiceInterface/Tags.cs diff --git a/MyApp.ServiceInterface/AiServer/CreateAnswerCommentTaskCommand.cs b/MyApp.ServiceInterface/AiServer/CreateAnswerCommentTaskCommand.cs index 20e2e93..5c3d85b 100644 --- a/MyApp.ServiceInterface/AiServer/CreateAnswerCommentTaskCommand.cs +++ b/MyApp.ServiceInterface/AiServer/CreateAnswerCommentTaskCommand.cs @@ -5,6 +5,7 @@ namespace MyApp.ServiceInterface.AiServer; +[Tag(Tags.AI)] public class CreateAnswerCommentTaskCommand(AppConfig appConfig) : IAsyncCommand { public const string SystemPrompt = diff --git a/MyApp.ServiceInterface/AiServer/CreateAnswerTasksCommand.cs b/MyApp.ServiceInterface/AiServer/CreateAnswerTasksCommand.cs index 4fc64d4..4ec1b6e 100644 --- a/MyApp.ServiceInterface/AiServer/CreateAnswerTasksCommand.cs +++ b/MyApp.ServiceInterface/AiServer/CreateAnswerTasksCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.AiServer; +[Tag(Tags.AI)] public class CreateAnswerTasksCommand(ILogger log, AppConfig appConfig, QuestionsProvider questions) : IAsyncCommand { diff --git a/MyApp.ServiceInterface/AiServer/CreateRankAnswerTaskCommand.cs b/MyApp.ServiceInterface/AiServer/CreateRankAnswerTaskCommand.cs index 00cedbb..26a47a5 100644 --- a/MyApp.ServiceInterface/AiServer/CreateRankAnswerTaskCommand.cs +++ b/MyApp.ServiceInterface/AiServer/CreateRankAnswerTaskCommand.cs @@ -4,6 +4,7 @@ namespace MyApp.ServiceInterface.AiServer; +[Tag(Tags.AI)] public class CreateRankAnswerTaskCommand(AppConfig appConfig, QuestionsProvider questions) : IAsyncCommand { //https://github.com/f/awesome-chatgpt-prompts?tab=readme-ov-file#act-as-a-tech-reviewer diff --git a/MyApp.ServiceInterface/App/AnswerAddedToPostCommand.cs b/MyApp.ServiceInterface/App/AnswerAddedToPostCommand.cs index 683f4b1..7ac23b4 100644 --- a/MyApp.ServiceInterface/App/AnswerAddedToPostCommand.cs +++ b/MyApp.ServiceInterface/App/AnswerAddedToPostCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Answers)] public class AnswerAddedToPostCommand(IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(AnswerAddedToPost request) diff --git a/MyApp.ServiceInterface/App/AppDbPeriodicTasksCommand.cs b/MyApp.ServiceInterface/App/AppDbPeriodicTasksCommand.cs index dac9033..b913dce 100644 --- a/MyApp.ServiceInterface/App/AppDbPeriodicTasksCommand.cs +++ b/MyApp.ServiceInterface/App/AppDbPeriodicTasksCommand.cs @@ -13,6 +13,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Database)] public class AppDbPeriodicTasksCommand(ILogger log, AppConfig appConfig, IDbConnectionFactory dbFactory, IMessageProducer mq, EmailRenderer renderer) : IAsyncCommand diff --git a/MyApp.ServiceInterface/App/CreateAnswerCommand.cs b/MyApp.ServiceInterface/App/CreateAnswerCommand.cs index 7dcf17c..cde5fbc 100644 --- a/MyApp.ServiceInterface/App/CreateAnswerCommand.cs +++ b/MyApp.ServiceInterface/App/CreateAnswerCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Answers)] public class CreateAnswerCommand(AppConfig appConfig, IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(Post answer) diff --git a/MyApp.ServiceInterface/App/CreateCommentVoteCommand.cs b/MyApp.ServiceInterface/App/CreateCommentVoteCommand.cs index ebd3e93..6dd0dcf 100644 --- a/MyApp.ServiceInterface/App/CreateCommentVoteCommand.cs +++ b/MyApp.ServiceInterface/App/CreateCommentVoteCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Database)] public class CreateCommentVoteCommand(IDbConnection db, QuestionsProvider questions) : IAsyncCommand { public async Task ExecuteAsync(Vote vote) diff --git a/MyApp.ServiceInterface/App/CreateFlagCommand.cs b/MyApp.ServiceInterface/App/CreateFlagCommand.cs index d63b038..0d51330 100644 --- a/MyApp.ServiceInterface/App/CreateFlagCommand.cs +++ b/MyApp.ServiceInterface/App/CreateFlagCommand.cs @@ -5,6 +5,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Database)] public class CreateFlagCommand(IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(Flag request) diff --git a/MyApp.ServiceInterface/App/CreateNotificationCommand.cs b/MyApp.ServiceInterface/App/CreateNotificationCommand.cs index ec7db0d..e5cf925 100644 --- a/MyApp.ServiceInterface/App/CreateNotificationCommand.cs +++ b/MyApp.ServiceInterface/App/CreateNotificationCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Notifications)] public class CreateNotificationCommand(AppConfig appConfig, IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(Notification request) diff --git a/MyApp.ServiceInterface/App/CreatePostCommand.cs b/MyApp.ServiceInterface/App/CreatePostCommand.cs index 32e5337..7520012 100644 --- a/MyApp.ServiceInterface/App/CreatePostCommand.cs +++ b/MyApp.ServiceInterface/App/CreatePostCommand.cs @@ -7,6 +7,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Questions)] public class CreatePostCommand(ILogger log, AppConfig appConfig, IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(Post post) diff --git a/MyApp.ServiceInterface/App/CreatePostVoteCommand.cs b/MyApp.ServiceInterface/App/CreatePostVoteCommand.cs index 33bab5c..e1b8ea3 100644 --- a/MyApp.ServiceInterface/App/CreatePostVoteCommand.cs +++ b/MyApp.ServiceInterface/App/CreatePostVoteCommand.cs @@ -7,6 +7,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Database)] public class CreatePostVoteCommand(AppConfig appConfig, IDbConnection db, IMessageProducer mqClient) : IAsyncCommand { public async Task ExecuteAsync(Vote vote) diff --git a/MyApp.ServiceInterface/App/DeleteAnswersCommand.cs b/MyApp.ServiceInterface/App/DeleteAnswersCommand.cs index a0e0807..a798daa 100644 --- a/MyApp.ServiceInterface/App/DeleteAnswersCommand.cs +++ b/MyApp.ServiceInterface/App/DeleteAnswersCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Answers)] public class DeleteAnswersCommand(IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(DeleteAnswers request) diff --git a/MyApp.ServiceInterface/App/DeleteCommentCommand.cs b/MyApp.ServiceInterface/App/DeleteCommentCommand.cs index 782fe04..3478209 100644 --- a/MyApp.ServiceInterface/App/DeleteCommentCommand.cs +++ b/MyApp.ServiceInterface/App/DeleteCommentCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Database)] public class DeleteCommentCommand(AppConfig appConfig, IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(DeleteComment request) diff --git a/MyApp.ServiceInterface/App/DeletePostsCommand.cs b/MyApp.ServiceInterface/App/DeletePostsCommand.cs index f899c7f..a411971 100644 --- a/MyApp.ServiceInterface/App/DeletePostsCommand.cs +++ b/MyApp.ServiceInterface/App/DeletePostsCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Database)] public class DeletePostsCommand(AppConfig appConfig, IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(DeletePosts request) diff --git a/MyApp.ServiceInterface/App/ImportQuestionCommand.cs b/MyApp.ServiceInterface/App/ImportQuestionCommand.cs index 4e1af0a..64a5f18 100644 --- a/MyApp.ServiceInterface/App/ImportQuestionCommand.cs +++ b/MyApp.ServiceInterface/App/ImportQuestionCommand.cs @@ -7,6 +7,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Questions)] public class ImportQuestionCommand(ILogger log, AppConfig appConfig) : IAsyncCommand { static readonly Regex ValidTagCharsRegex = new("[^a-zA-Z0-9#+.]", RegexOptions.Compiled); diff --git a/MyApp.ServiceInterface/App/MarkAsReadCommand.cs b/MyApp.ServiceInterface/App/MarkAsReadCommand.cs index ced9afe..ac6a871 100644 --- a/MyApp.ServiceInterface/App/MarkAsReadCommand.cs +++ b/MyApp.ServiceInterface/App/MarkAsReadCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Notifications)] public class MarkAsReadCommand(AppConfig appConfig, IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(MarkAsRead request) diff --git a/MyApp.ServiceInterface/App/MarkPostAsReadCommand.cs b/MyApp.ServiceInterface/App/MarkPostAsReadCommand.cs index 11f1243..f37186a 100644 --- a/MyApp.ServiceInterface/App/MarkPostAsReadCommand.cs +++ b/MyApp.ServiceInterface/App/MarkPostAsReadCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Notifications)] public class MarkPostAsReadCommand(AppConfig appConfig, IDbConnection db, QuestionsProvider questions) : IAsyncCommand { public async Task ExecuteAsync(MarkPostAsRead request) diff --git a/MyApp.ServiceInterface/App/NewCommentCommand.cs b/MyApp.ServiceInterface/App/NewCommentCommand.cs index 441e20d..fbc5aac 100644 --- a/MyApp.ServiceInterface/App/NewCommentCommand.cs +++ b/MyApp.ServiceInterface/App/NewCommentCommand.cs @@ -6,6 +6,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Database)] public class NewCommentCommand(AppConfig appConfig, IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(NewComment request) diff --git a/MyApp.ServiceInterface/App/PostSubscriptionsCommand.cs b/MyApp.ServiceInterface/App/PostSubscriptionsCommand.cs index 21934bd..1a7f0c3 100644 --- a/MyApp.ServiceInterface/App/PostSubscriptionsCommand.cs +++ b/MyApp.ServiceInterface/App/PostSubscriptionsCommand.cs @@ -5,6 +5,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Notifications)] public class PostSubscriptionsCommand(IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(PostSubscriptions request) diff --git a/MyApp.ServiceInterface/App/SaveGradeResultCommand.cs b/MyApp.ServiceInterface/App/SaveGradeResultCommand.cs index e4eadfe..0b1b2ef 100644 --- a/MyApp.ServiceInterface/App/SaveGradeResultCommand.cs +++ b/MyApp.ServiceInterface/App/SaveGradeResultCommand.cs @@ -7,6 +7,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Answers)] public class SaveGradeResultCommand(AppConfig appConfig, IDbConnection db, IMessageProducer mq, WorkerAnswerNotifier answerNotifier) : IAsyncCommand { diff --git a/MyApp.ServiceInterface/App/TagSubscriptionsCommand.cs b/MyApp.ServiceInterface/App/TagSubscriptionsCommand.cs index d1bd4e2..ac6e3ee 100644 --- a/MyApp.ServiceInterface/App/TagSubscriptionsCommand.cs +++ b/MyApp.ServiceInterface/App/TagSubscriptionsCommand.cs @@ -5,6 +5,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Notifications)] public class TagSubscriptionsCommand(IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(TagSubscriptions request) diff --git a/MyApp.ServiceInterface/App/UpdatePostCommand.cs b/MyApp.ServiceInterface/App/UpdatePostCommand.cs index c2b897e..fea1d06 100644 --- a/MyApp.ServiceInterface/App/UpdatePostCommand.cs +++ b/MyApp.ServiceInterface/App/UpdatePostCommand.cs @@ -5,6 +5,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Questions)] public class UpdatePostCommand(IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(Post question) diff --git a/MyApp.ServiceInterface/App/UpdateReputationsCommand.cs b/MyApp.ServiceInterface/App/UpdateReputationsCommand.cs index 964c7e3..1b3027c 100644 --- a/MyApp.ServiceInterface/App/UpdateReputationsCommand.cs +++ b/MyApp.ServiceInterface/App/UpdateReputationsCommand.cs @@ -4,6 +4,7 @@ namespace MyApp.ServiceInterface.App; +[Tag(Tags.Notifications)] public class UpdateReputationsCommand(AppConfig appConfig, IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(UpdateReputations request) diff --git a/MyApp.ServiceInterface/CreatorKit/SendMailRunCommand.cs b/MyApp.ServiceInterface/CreatorKit/SendMailRunCommand.cs index d50a8be..3c3ca82 100644 --- a/MyApp.ServiceInterface/CreatorKit/SendMailRunCommand.cs +++ b/MyApp.ServiceInterface/CreatorKit/SendMailRunCommand.cs @@ -9,6 +9,7 @@ namespace MyApp.ServiceInterface.CreatorKit; +[Tag(Tags.CreatorKit)] public class SendMailRunCommand( ILogger log, IDbConnectionFactory dbFactory, diff --git a/MyApp.ServiceInterface/CreatorKit/SendMessagesCommand.cs b/MyApp.ServiceInterface/CreatorKit/SendMessagesCommand.cs index 2ff860c..277372c 100644 --- a/MyApp.ServiceInterface/CreatorKit/SendMessagesCommand.cs +++ b/MyApp.ServiceInterface/CreatorKit/SendMessagesCommand.cs @@ -1,5 +1,6 @@ using CreatorKit.ServiceModel.Types; using MyApp.Data; +using MyApp.ServiceInterface; using MyApp.ServiceModel; using ServiceStack; using ServiceStack.Data; @@ -7,6 +8,7 @@ namespace CreatorKit.ServiceInterface; +[Tag(Tags.CreatorKit)] public class SendMessagesCommand(IDbConnectionFactory dbFactory, EmailProvider emailProvider) : IAsyncCommand { public async Task ExecuteAsync(SendMailMessages request) diff --git a/MyApp.ServiceInterface/Data/Tasks.cs b/MyApp.ServiceInterface/Data/Tasks.cs index 875771c..780d3fd 100644 --- a/MyApp.ServiceInterface/Data/Tasks.cs +++ b/MyApp.ServiceInterface/Data/Tasks.cs @@ -1,6 +1,7 @@ using MyApp.ServiceInterface; using MyApp.ServiceInterface.AiServer; using MyApp.ServiceInterface.App; +using MyApp.ServiceInterface.Jobs; using MyApp.ServiceModel; using ServiceStack; using ServiceStack.DataAnnotations; diff --git a/MyApp.ServiceInterface/App/CompletePostJobsCommand.cs b/MyApp.ServiceInterface/Jobs/CompletePostJobsCommand.cs similarity index 77% rename from MyApp.ServiceInterface/App/CompletePostJobsCommand.cs rename to MyApp.ServiceInterface/Jobs/CompletePostJobsCommand.cs index 9f004f9..1347fe4 100644 --- a/MyApp.ServiceInterface/App/CompletePostJobsCommand.cs +++ b/MyApp.ServiceInterface/Jobs/CompletePostJobsCommand.cs @@ -1,28 +1,29 @@ using System.Data; +using MyApp.Data; +using MyApp.ServiceModel; using ServiceStack; using ServiceStack.Messaging; using ServiceStack.OrmLite; -using MyApp.Data; -using MyApp.ServiceModel; -namespace MyApp.ServiceInterface.App; +namespace MyApp.ServiceInterface.Jobs; -public class CompletePostJobsCommand(IDbConnection Db, ModelWorkerQueue modelWorkers, IMessageProducer mqClient) : IAsyncCommand +[Tag(Tags.Jobs)] +public class CompletePostJobsCommand(IDbConnection db, ModelWorkerQueue modelWorkers, IMessageProducer mqClient) : IAsyncCommand { public async Task ExecuteAsync(CompletePostJobs request) { var jobIds = request.Ids; - await Db.UpdateOnlyAsync(() => new PostJob { + await db.UpdateOnlyAsync(() => new PostJob { CompletedDate = DateTime.UtcNow, }, x => jobIds.Contains(x.Id)); - var postJobs = await Db.SelectAsync(Db.From() + var postJobs = await db.SelectAsync(db.From() .Where(x => jobIds.Contains(x.Id))); foreach (var postJob in postJobs) { // If there's no outstanding model answer jobs for this post, add a rank job - if (!await Db.ExistsAsync(Db.From() + if (!await db.ExistsAsync(db.From() .Where(x => x.PostId == postJob.PostId && x.CompletedDate == null))) { var rankJob = new PostJob @@ -33,7 +34,7 @@ public async Task ExecuteAsync(CompletePostJobs request) CreatedDate = DateTime.UtcNow, CreatedBy = nameof(DbWrites), }; - await Db.InsertAsync(rankJob); + await db.InsertAsync(rankJob); modelWorkers.Enqueue(rankJob); mqClient.Publish(new SearchTasks { AddPostToIndex = postJob.PostId }); } diff --git a/MyApp.ServiceInterface/App/CreatePostJobsCommand.cs b/MyApp.ServiceInterface/Jobs/CreatePostJobsCommand.cs similarity index 87% rename from MyApp.ServiceInterface/App/CreatePostJobsCommand.cs rename to MyApp.ServiceInterface/Jobs/CreatePostJobsCommand.cs index daccee3..4e25ab6 100644 --- a/MyApp.ServiceInterface/App/CreatePostJobsCommand.cs +++ b/MyApp.ServiceInterface/Jobs/CreatePostJobsCommand.cs @@ -1,10 +1,11 @@ using System.Data; +using MyApp.Data; using ServiceStack; using ServiceStack.OrmLite; -using MyApp.Data; -namespace MyApp.ServiceInterface.App; +namespace MyApp.ServiceInterface.Jobs; +[Tag(Tags.Jobs)] public class CreatePostJobsCommand(IDbConnection db, ModelWorkerQueue modelWorkers) : IAsyncCommand { public async Task ExecuteAsync(CreatePostJobs request) diff --git a/MyApp.ServiceInterface/App/FailJobCommand.cs b/MyApp.ServiceInterface/Jobs/FailJobCommand.cs similarity index 94% rename from MyApp.ServiceInterface/App/FailJobCommand.cs rename to MyApp.ServiceInterface/Jobs/FailJobCommand.cs index b28a055..dd636b0 100644 --- a/MyApp.ServiceInterface/App/FailJobCommand.cs +++ b/MyApp.ServiceInterface/Jobs/FailJobCommand.cs @@ -1,11 +1,12 @@ using System.Data; -using ServiceStack; -using ServiceStack.OrmLite; using MyApp.Data; using MyApp.ServiceModel; +using ServiceStack; +using ServiceStack.OrmLite; -namespace MyApp.ServiceInterface.App; +namespace MyApp.ServiceInterface.Jobs; +[Tag(Tags.Jobs)] public class FailJobCommand(IDbConnection db, ModelWorkerQueue modelWorkers) : IAsyncCommand { public async Task ExecuteAsync(FailJob request) diff --git a/MyApp.ServiceInterface/App/StartJobCommand.cs b/MyApp.ServiceInterface/Jobs/StartJobCommand.cs similarity index 89% rename from MyApp.ServiceInterface/App/StartJobCommand.cs rename to MyApp.ServiceInterface/Jobs/StartJobCommand.cs index 4cada31..954039b 100644 --- a/MyApp.ServiceInterface/App/StartJobCommand.cs +++ b/MyApp.ServiceInterface/Jobs/StartJobCommand.cs @@ -1,11 +1,12 @@ using System.Data; -using ServiceStack; -using ServiceStack.OrmLite; using MyApp.Data; using MyApp.ServiceModel; +using ServiceStack; +using ServiceStack.OrmLite; -namespace MyApp.ServiceInterface.App; +namespace MyApp.ServiceInterface.Jobs; +[Tag(Tags.Jobs)] public class StartJobCommand(IDbConnection db) : IAsyncCommand { public async Task ExecuteAsync(StartJob job) diff --git a/MyApp.ServiceInterface/Renderers/RegenerateMetaCommand.cs b/MyApp.ServiceInterface/Renderers/RegenerateMetaCommand.cs index 444b52e..0236dd2 100644 --- a/MyApp.ServiceInterface/Renderers/RegenerateMetaCommand.cs +++ b/MyApp.ServiceInterface/Renderers/RegenerateMetaCommand.cs @@ -9,6 +9,7 @@ namespace MyApp.ServiceInterface.Renderers; +[Tag(Tags.Renderer)] public class RegenerateMetaCommand( ILogger log, IDbConnectionFactory dbFactory, diff --git a/MyApp.ServiceInterface/Tags.cs b/MyApp.ServiceInterface/Tags.cs new file mode 100644 index 0000000..7a486b8 --- /dev/null +++ b/MyApp.ServiceInterface/Tags.cs @@ -0,0 +1,13 @@ +namespace MyApp.ServiceInterface; + +public class Tags +{ + public const string Database = nameof(Database); + public const string Questions = nameof(Questions); + public const string Answers = nameof(Answers); + public const string Notifications = nameof(Notifications); + public const string Jobs = nameof(Jobs); + public const string CreatorKit = nameof(CreatorKit); + public const string AI = nameof(AI); + public const string Renderer = nameof(Renderer); +} \ No newline at end of file diff --git a/MyApp.Tests/Top1KQuestionTasks.cs b/MyApp.Tests/Top1KQuestionTasks.cs index 76fcfeb..64d5bd0 100644 --- a/MyApp.Tests/Top1KQuestionTasks.cs +++ b/MyApp.Tests/Top1KQuestionTasks.cs @@ -114,6 +114,22 @@ public async Task Recreate_answers_for_Top1K_questions_for_gemini_pro_15() apiCreate.Response!.Results.PrintDump();; } + [Test] + public async Task Recreate_answers_for_Top1K_questions_for_gemini_flash() + { + var client = await TestUtils.CreateAuthenticatedProdClientAsync(); + var apiCreate = await client.ApiAsync(new CreateAnswersForModels + { + Models = ["gemini-flash"], + PostIds = Migration1005.Top1KIds, + }); + + apiCreate.Error.PrintDump(); + apiCreate.ThrowIfError(); + apiCreate.Response!.Errors.PrintDump(); + apiCreate.Response!.Results.PrintDump();; + } + [Test] public async Task Find_answers_that_have_not_been_individually_graded() { @@ -176,4 +192,29 @@ public async Task Create_Gemini_Pro_15_User() api.Response.PrintDump(); api.ThrowIfError(); } + + [Test] + public async Task Generate_top_10k_answers_for_gemini_flash() + { + var txt = await File.ReadAllTextAsync(TestUtils.GetHostDir().CombineWith("App_Data/top10k-6.txt")); + var ids = new List(); + foreach (var line in txt.ReadLines()) + { + ids.Add(int.Parse(line.Trim())); + } + + var client = await TestUtils.CreateAuthenticatedProdClientAsync(); + // client.GetHttpClient().Timeout = TimeSpan.FromMinutes(5); + var apiCreate = await client.ApiAsync(new CreateAnswersForModels + { + // Models = ["gemini-flash","gemini-pro-1.5"], + Models = ["gemini-flash"], + PostIds = ids, + }); + + apiCreate.Error.PrintDump(); + apiCreate.ThrowIfError(); + apiCreate.Response!.Errors.PrintDump(); + apiCreate.Response!.Results.PrintDump();; + } } \ No newline at end of file diff --git a/MyApp/Configure.Renderer.cs b/MyApp/Configure.Renderer.cs index b8fd235..369dbf3 100644 --- a/MyApp/Configure.Renderer.cs +++ b/MyApp/Configure.Renderer.cs @@ -52,6 +52,7 @@ protected override void NavigateToCore(string uri, bool forceLoad) } } +[Tag(Tags.Renderer)] public class RenderQuestionPostCommand(BlazorRenderer renderer, RendererCache cache) : IAsyncCommand { public async Task ExecuteAsync(QuestionAndAnswers request) @@ -61,6 +62,7 @@ public async Task ExecuteAsync(QuestionAndAnswers request) } } +[Tag(Tags.Renderer)] public class RenderHomeTabCommand(BlazorRenderer renderer, RendererCache cache) : IAsyncCommand { public async Task ExecuteAsync(RenderHome request)