Skip to content

Commit

Permalink
updated by review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yhsiang committed Aug 7, 2023
1 parent c66b644 commit d2734ab
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/graphql/models/Article.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,7 @@ const Article = new GraphQLObjectType({
type: 'doc',
body: {
query: {
bool: {
should: [{ term: { articleIds: id } }],
},
term: { articleIds: id },
},
},
}),
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/models/Cooccurrence.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const Cooccurrence = new GraphQLObjectType({
new GraphQLList(new GraphQLNonNull(GraphQLString))
),
},
createdAt: { type: GraphQLString },
updatedAt: { type: GraphQLString },
createdAt: { type: new GraphQLNonNull(GraphQLString) },
updatedAt: { type: new GraphQLNonNull(GraphQLString) },
}),
});

Expand Down
4 changes: 2 additions & 2 deletions src/graphql/mutations/CreateOrUpdateCooccurrence.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function createOrUpdateCooccurrence({ articleIds, user }) {
const isCreated = result === 'created';

return {
cooccurence: { ..._source },
cooccurrence: { ..._source },
isCreated,
};
}
Expand All @@ -72,6 +72,6 @@ export default {
articleIds,
user,
});
return result.cooccurence;
return result.cooccurrence;
},
};
3 changes: 0 additions & 3 deletions src/graphql/queries/ListCooccurrences.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export default {
track_scores: true, // for _score sorting
};

const shouldQueries = []; // Affects scores
const filterQueries = [];

if (filter.updatedAt) {
Expand All @@ -51,8 +50,6 @@ export default {

body.query = {
bool: {
should:
shouldQueries.length === 0 ? [{ match_all: {} }] : shouldQueries,
filter: filterQueries,
minimum_should_match: 1, // At least 1 "should" query should present
},
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/queries/__fixtures__/ListCooccurrences.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ export default {
userId: 'user1',
appId: 'app1',
articleIds: ['a1', 'a2'],
updatedAt: 1,
updatedAt: '2020-02-03T00:01:00.000Z',
createdAt: '2020-02-03T00:00:00.000Z',
},
'/cooccurrences/doc/listCooccurrenceTest2': {
userId: 'user1',
appId: 'app1',
articleIds: ['a1', 'a3'],
updatedAt: 1,
updatedAt: '2020-02-03T00:02:00.000Z',
createdAt: '2020-02-03T00:00:00.000Z',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ Object {
Object {
"node": Object {
"id": "listCooccurrenceTest2",
"updatedAt": "1",
"updatedAt": "2020-02-03T00:02:00.000Z",
},
},
Object {
"node": Object {
"id": "listCooccurrenceTest1",
"updatedAt": "1",
"updatedAt": "2020-02-03T00:01:00.000Z",
},
},
],
"pageInfo": Object {
"firstCursor": "WzEsImxpc3RDb29jY3VycmVuY2VUZXN0MiJd",
"lastCursor": "WzEsImxpc3RDb29jY3VycmVuY2VUZXN0MSJd",
"firstCursor": "WzE1ODA2ODgxMjAwMDAsImxpc3RDb29jY3VycmVuY2VUZXN0MiJd",
"lastCursor": "WzE1ODA2ODgwNjAwMDAsImxpc3RDb29jY3VycmVuY2VUZXN0MSJd",
},
"totalCount": 2,
},
Expand Down

0 comments on commit d2734ab

Please sign in to comment.