feat: introduce asset action count caching

This commit is contained in:
Wyatt Johnson
2018-09-23 20:43:43 -06:00
parent 0e25c8d446
commit d8417eda2e
5 changed files with 64 additions and 16 deletions
+13 -1
View File
@@ -7,7 +7,10 @@ import {
createActions,
encodeActionCounts,
} from "talk-server/models/actions";
import { retrieveAsset } from "talk-server/models/asset";
import {
retrieveAsset,
updateAssetActionCounts,
} from "talk-server/models/asset";
import {
Comment,
createComment,
@@ -85,6 +88,7 @@ export async function create(
// Insert and handle creating the actions.
comment = await addCommentActions(mongo, tenant, comment, inputs);
// asse
}
if (input.parent_id) {
@@ -196,6 +200,14 @@ async function addCommentActions(
actionCounts
);
// Update the Asset with the updated action counts.
await updateAssetActionCounts(
mongo,
tenant.id,
comment.asset_id,
actionCounts
);
// Check to see if there was an actual comment returned (there should
// have been, we just created it!).
if (!updatedComment) {