[CORL-836] Create activeStories endpoint (#2787)

* Create activeStories GraphQL query endpoint

Set lastCommentedAt on stories when they are
commented upon.
Use lastCommentedAt to retrieve the activeStories.
Create a migration to partial index
lastCommentedAt on stories to make retrieval fast.

CORL-836

* fix: adjusted query to use index, more @auth directives

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
This commit is contained in:
Nick Funk
2020-01-10 16:55:22 -07:00
committed by Wyatt Johnson
parent 745fb4056c
commit a88644d98e
8 changed files with 143 additions and 31 deletions
+8 -2
View File
@@ -25,7 +25,10 @@ import {
hasAncestors,
hasPublishedStatus,
} from "coral-server/models/comment/helpers";
import { retrieveStory } from "coral-server/models/story";
import {
retrieveStory,
updateStoryLastCommentedAt,
} from "coral-server/models/story";
import { Tenant } from "coral-server/models/tenant";
import { User } from "coral-server/models/user";
import {
@@ -174,7 +177,10 @@ export default async function create(
now
);
await updateUserLastCommentID(redis, tenant, author, comment.id);
await Promise.all([
updateUserLastCommentID(redis, tenant, author, comment.id),
updateStoryLastCommentedAt(mongo, tenant.id, story.id, now),
]);
// Pull the revision out.
const revision = getLatestRevision(comment);