From 75125993b9604b3cdf7b8da57d8cf7d7d6c58174 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 29 Aug 2017 10:21:31 -0600 Subject: [PATCH 1/2] Added patch for missing action summary type --- client/coral-framework/utils/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/coral-framework/utils/index.js b/client/coral-framework/utils/index.js index df264d360..26f6b627e 100644 --- a/client/coral-framework/utils/index.js +++ b/client/coral-framework/utils/index.js @@ -185,10 +185,15 @@ export function getShallowChanges(a, b) { .filter((key) => a[key] !== b[key]); } +// TODO: replace with something less fragile. +// NOT_REACTION_TYPES are the action summaries that are not reactions. +const NOT_REACTION_TYPES = [ + 'FlagActionSummary', + 'DontAgreeActionSummary', +]; + export function getTotalReactionsCount(actionSummaries) { return actionSummaries - .filter((s) => s.__typename !== 'FlagActionSummary') - .reduce((total, summary) => { - return total + summary.count; - }, 0); + .filter(({__typename}) => !NOT_REACTION_TYPES.includes(__typename)) + .reduce((total, {count}) => total + count, 0); } From c786805505172058e24c5eb4c1c751147d22c607 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 29 Aug 2017 10:28:30 -0600 Subject: [PATCH 2/2] small bug fix --- test/server/graph/queries/asset.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/server/graph/queries/asset.js b/test/server/graph/queries/asset.js index 4d96be74a..ba605dfd7 100644 --- a/test/server/graph/queries/asset.js +++ b/test/server/graph/queries/asset.js @@ -34,7 +34,7 @@ describe('graph.queries.asset', () => { username: 'usernameC' } ]); - comments = await CommentsService.publicCreate([0, 1, 0, 1].map((idx) => ({ + comments = await CommentsService.publicCreate([0, 0, 1, 1].map((idx) => ({ author_id: users[idx].id, asset_id: assets[idx].id, body: `hello there! ${String(Math.random()).slice(2)}`, @@ -74,12 +74,12 @@ describe('graph.queries.asset', () => { expect(asset.nodes).to.have.length(2); expect(asset.hasNextPage).to.be.false; - expect(asset.nodes[0]).to.have.property('id', comments[2].id); + expect(asset.nodes[0]).to.have.property('id', comments[1].id); expect(asset.nodes[1]).to.have.property('id', comments[0].id); expect(otherAsset.nodes).to.have.length(2); expect(otherAsset.hasNextPage).to.be.false; expect(otherAsset.nodes[0]).to.have.property('id', comments[3].id); - expect(otherAsset.nodes[1]).to.have.property('id', comments[1].id); + expect(otherAsset.nodes[1]).to.have.property('id', comments[2].id); for (let node of asset.nodes) { for (let otherNode of otherAsset.nodes) {