Faster forum denormalization
This commit is contained in:
parent
4263b32515
commit
88cdd8443a
|
@ -30,8 +30,15 @@ final class PostApi(env: ForumEnv, maxPerPage: Int) {
|
|||
text = data.text,
|
||||
number = number + 1)
|
||||
_ ← env.postRepo saveIO post
|
||||
_ ← env.topicApi denormalize topic
|
||||
_ ← env.categApi denormalize categ
|
||||
// denormalize topic
|
||||
_ ← env.topicRepo saveIO topic.copy(
|
||||
nbPosts = topic.nbPosts + 1,
|
||||
lastPostId = post.id,
|
||||
updatedAt = post.createdAt)
|
||||
// denormalize categ
|
||||
_ ← env.categRepo saveIO categ.copy(
|
||||
nbPosts = categ.nbPosts + 1,
|
||||
lastPostId = post.id)
|
||||
_ ← env.recent.invalidate
|
||||
} yield post
|
||||
|
||||
|
|
|
@ -33,10 +33,17 @@ final class TopicApi(env: ForumEnv, maxPerPage: Int) {
|
|||
userId = user map (_.id),
|
||||
text = data.post.text,
|
||||
number = 1)
|
||||
_ ← env.topicRepo saveIO topic
|
||||
_ ← env.postRepo saveIO post
|
||||
_ ← env.topicApi denormalize topic
|
||||
_ ← env.categApi denormalize categ
|
||||
// denormalize topic
|
||||
_ ← env.topicRepo saveIO topic.copy(
|
||||
nbPosts = categ.nbPosts + 1,
|
||||
lastPostId = post.id,
|
||||
updatedAt = post.createdAt)
|
||||
// denormalize categ
|
||||
_ ← env.categRepo saveIO categ.copy(
|
||||
nbTopics = categ.nbTopics + 1,
|
||||
nbPosts = categ.nbPosts + 1,
|
||||
lastPostId = post.id)
|
||||
_ ← env.recent.invalidate
|
||||
} yield topic
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ title = trans.forum.str()) {
|
|||
<table class="categories">
|
||||
<thead>
|
||||
<tr class="thead">
|
||||
<th>Categories</th>
|
||||
<th></th>
|
||||
<th class="right">Topics</th>
|
||||
<th class="right">Posts</th>
|
||||
<th>Last Post</th>
|
||||
|
|
|
@ -19,7 +19,7 @@ title = categ.name) {
|
|||
<table class="forum_topics_list">
|
||||
<thead>
|
||||
<tr class="thead">
|
||||
<th>Topics</th>
|
||||
<th></th>
|
||||
<th class="right">Views</th>
|
||||
<th class="right">Replies</th>
|
||||
<th>Last Post</th>
|
||||
|
|
Loading…
Reference in a new issue