Faster forum denormalization

This commit is contained in:
Thibault Duplessis 2012-05-31 22:10:13 +02:00
parent 4263b32515
commit 88cdd8443a
5 changed files with 22 additions and 7 deletions

View file

@ -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

View file

@ -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

View file

@ -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>

View file

@ -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>

1
todo
View file

@ -34,6 +34,7 @@ guess friend list
do forum denormalization with mongodb mapReduce
profile edition
nb-playing is wrong (mongo date?)
reverse captcha board
new translations:
-rematchOfferCanceled=Rematch offer canceled