Skip to content

Commit

Permalink
Replace UpdatePostCommand with DB Lock
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Aug 20, 2024
1 parent 2f21b84 commit 343872c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 28 deletions.
1 change: 0 additions & 1 deletion MyApp.ServiceInterface/App/PostSubscriptionsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class PostSubscriptions
public List<int>? Unsubscriptions { get; set; }
}


[Worker(Databases.App)]
[Tag(Tags.Notifications)]
public class PostSubscriptionsCommand(IDbConnection db) : SyncCommand<PostSubscriptions>
Expand Down
25 changes: 0 additions & 25 deletions MyApp.ServiceInterface/App/UpdatePostCommand.cs

This file was deleted.

14 changes: 13 additions & 1 deletion MyApp.ServiceInterface/QuestionServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,19 @@ public async Task<object> Any(UpdateQuestion request)
question.LastActivityDate = DateTime.UtcNow;
question.LastEditDate = question.LastActivityDate;

jobs.RunCommand<UpdatePostCommand>(question);
lock (Workers.AppDb)
{
Db.UpdateOnly(() => new Post
{
Title = question.Title,
Tags = question.Tags,
Slug = question.Slug,
Summary = question.Summary,
ModifiedBy = question.ModifiedBy,
LastActivityDate = question.LastActivityDate,
LastEditDate = question.LastEditDate,
}, x => x.Id == question.Id);
}
await questions.SaveQuestionEditAsync(question);

return new UpdateQuestionResponse
Expand Down
2 changes: 1 addition & 1 deletion MyApp.ServiceInterface/UserServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public async Task<object> Any(ShareContent request)
return HttpResult.Redirect($"/questions/{postId}/{post.Slug}" + (request.RefId.IndexOf('-') >= 0 ? $"#{request.RefId}" : ""));
}

public async Task<object> Any(FlagContent request)
public object Any(FlagContent request)
{
var postId = request.RefId.LeftPart('-').ToInt();
var post = Db.SingleById<Post>(postId);
Expand Down

0 comments on commit 343872c

Please sign in to comment.