mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 12:39:33 +08:00
changed sort -> sortOrder
This commit is contained in:
@@ -22,10 +22,10 @@ class DashboardContainer extends React.Component {
|
||||
|
||||
export const witDashboardQuery = withQuery(gql`
|
||||
query CoralAdmin_Dashboard($from: Date!, $to: Date!) {
|
||||
assetsByFlag: assetMetrics(from: $from, to: $to, sort: FLAG) {
|
||||
assetsByFlag: assetMetrics(from: $from, to: $to, sortBy: FLAG) {
|
||||
...CoralAdmin_Metrics
|
||||
}
|
||||
assetsByActivity: assetMetrics(from: $from, to: $to, sort: ACTIVITY) {
|
||||
assetsByActivity: assetMetrics(from: $from, to: $to, sortBy: ACTIVITY) {
|
||||
...CoralAdmin_Metrics
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class ModerationContainer extends Component {
|
||||
return handleCommentChange(
|
||||
root,
|
||||
comment,
|
||||
this.props.data.variables.sort,
|
||||
this.props.data.variables.sortOrder,
|
||||
() => notifyText && this.props.notify('info', notifyText),
|
||||
this.props.queueConfig,
|
||||
this.activeTab
|
||||
@@ -168,7 +168,7 @@ class ModerationContainer extends Component {
|
||||
const variables = {
|
||||
limit: 10,
|
||||
cursor: this.props.root[tab].endCursor,
|
||||
sort: this.props.data.variables.sort,
|
||||
sortOrder: this.props.data.variables.sortOrder,
|
||||
asset_id: this.props.data.variables.asset_id,
|
||||
statuses: this.props.queueConfig[tab].statuses,
|
||||
action_type: this.props.queueConfig[tab].action_type,
|
||||
@@ -288,8 +288,8 @@ const COMMENT_REJECTED_SUBSCRIPTION = gql`
|
||||
`;
|
||||
|
||||
const LOAD_MORE_QUERY = gql`
|
||||
query CoralAdmin_Moderation_LoadMore($limit: Int = 10, $cursor: Cursor, $sort: SORT_ORDER, $asset_id: ID, $statuses:[COMMENT_STATUS!], $action_type: ACTION_TYPE) {
|
||||
comments(query: {limit: $limit, cursor: $cursor, asset_id: $asset_id, statuses: $statuses, sort: $sort, action_type: $action_type}) {
|
||||
query CoralAdmin_Moderation_LoadMore($limit: Int = 10, $cursor: Cursor, $sortOrder: SORT_ORDER, $asset_id: ID, $statuses:[COMMENT_STATUS!], $action_type: ACTION_TYPE) {
|
||||
comments(query: {limit: $limit, cursor: $cursor, asset_id: $asset_id, statuses: $statuses, sortOrder: $sortOrder, action_type: $action_type}) {
|
||||
nodes {
|
||||
...${getDefinitionName(Comment.fragments.comment)}
|
||||
}
|
||||
@@ -314,14 +314,14 @@ const commentConnectionFragment = gql`
|
||||
`;
|
||||
|
||||
const withModQueueQuery = withQuery(({queueConfig}) => gql`
|
||||
query CoralAdmin_Moderation($asset_id: ID, $sort: SORT_ORDER, $allAssets: Boolean!) {
|
||||
query CoralAdmin_Moderation($asset_id: ID, $sortOrder: SORT_ORDER, $allAssets: Boolean!) {
|
||||
${Object.keys(queueConfig).map((queue) => `
|
||||
${queue}: comments(query: {
|
||||
${queueConfig[queue].statuses ? `statuses: [${queueConfig[queue].statuses.join(', ')}],` : ''}
|
||||
${queueConfig[queue].tags ? `tags: ["${queueConfig[queue].tags.join('", "')}"],` : ''}
|
||||
${queueConfig[queue].action_type ? `action_type: ${queueConfig[queue].action_type}` : ''}
|
||||
asset_id: $asset_id,
|
||||
sort: $sort
|
||||
sortOrder: $sortOrder
|
||||
}) {
|
||||
...CoralAdmin_Moderation_CommentConnection
|
||||
}
|
||||
@@ -354,7 +354,7 @@ const withModQueueQuery = withQuery(({queueConfig}) => gql`
|
||||
return {
|
||||
variables: {
|
||||
asset_id: id,
|
||||
sort: props.moderation.sortOrder,
|
||||
sortOrder: props.moderation.sortOrder,
|
||||
allAssets: id === null
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,29 +28,29 @@ function removeCommentFromQueue(root, queue, id) {
|
||||
});
|
||||
}
|
||||
|
||||
function shouldCommentBeAdded(root, queue, comment, sort) {
|
||||
function shouldCommentBeAdded(root, queue, comment, sortOrder) {
|
||||
if (root[`${queue}Count`] < limit) {
|
||||
|
||||
// Adding all comments until first limit has reached.
|
||||
return true;
|
||||
}
|
||||
const cursor = new Date(root[queue].endCursor);
|
||||
return sort === 'ASC'
|
||||
return sortOrder === 'ASC'
|
||||
? new Date(comment.created_at) <= cursor
|
||||
: new Date(comment.created_at) >= cursor;
|
||||
}
|
||||
|
||||
function addCommentToQueue(root, queue, comment, sort) {
|
||||
function addCommentToQueue(root, queue, comment, sortOrder) {
|
||||
if (queueHasComment(root, queue, comment.id)) {
|
||||
return root;
|
||||
}
|
||||
|
||||
const sortAlgo = sort === 'ASC' ? ascending : descending;
|
||||
const sortAlgo = sortOrder === 'ASC' ? ascending : descending;
|
||||
const changes = {
|
||||
[`${queue}Count`]: {$set: root[`${queue}Count`] + 1},
|
||||
};
|
||||
|
||||
if (shouldCommentBeAdded(root, queue, comment, sort)) {
|
||||
if (shouldCommentBeAdded(root, queue, comment, sortOrder)) {
|
||||
const nodes = root[queue].nodes.concat(comment).sort(sortAlgo);
|
||||
changes[queue] = {
|
||||
nodes: {$set: nodes},
|
||||
@@ -90,13 +90,13 @@ function getCommentQueues(comment, queueConfig) {
|
||||
* Assimilate comment changes into current store.
|
||||
* @param {Object} root current state of the store
|
||||
* @param {Object} comment comment that was changed
|
||||
* @param {string} sort current sort order of the queues
|
||||
* @param {string} sortOrder current sort order of the queues
|
||||
* @param {string} notify callback to show notification
|
||||
* in the current active queue besides the 'all' queue.
|
||||
* @param {Object} queueConfig queue configuration
|
||||
* @return {Object} next state of the store
|
||||
*/
|
||||
export function handleCommentChange(root, comment, sort, notify, queueConfig, activeQueue) {
|
||||
export function handleCommentChange(root, comment, sortOrder, notify, queueConfig, activeQueue) {
|
||||
let next = root;
|
||||
|
||||
const nextQueues = getCommentQueues(comment, queueConfig);
|
||||
@@ -113,8 +113,8 @@ export function handleCommentChange(root, comment, sort, notify, queueConfig, ac
|
||||
Object.keys(queueConfig).forEach((queue) => {
|
||||
if (nextQueues.indexOf(queue) >= 0) {
|
||||
if (!queueHasComment(next, queue, comment.id)) {
|
||||
next = addCommentToQueue(next, queue, comment, sort);
|
||||
if (notify && activeQueue === queue && shouldCommentBeAdded(next, queue, comment, sort)) {
|
||||
next = addCommentToQueue(next, queue, comment, sortOrder);
|
||||
if (notify && activeQueue === queue && shouldCommentBeAdded(next, queue, comment, sortOrder)) {
|
||||
showNotificationOnce();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ const LOAD_MORE_QUERY = gql`
|
||||
cursor: $cursor
|
||||
parent_id: $parent_id
|
||||
asset_id: $asset_id
|
||||
sort: $sortOrder
|
||||
sortOrder: $sortOrder
|
||||
sortBy: $sortBy
|
||||
excludeIgnored: $excludeIgnored
|
||||
}
|
||||
@@ -328,7 +328,7 @@ const fragments = {
|
||||
}
|
||||
commentCount @skip(if: $hasComment)
|
||||
totalCommentCount @skip(if: $hasComment)
|
||||
comments(query: {limit: 10, excludeIgnored: $excludeIgnored, sort: $sortOrder, sortBy: $sortBy}) @skip(if: $hasComment) {
|
||||
comments(query: {limit: 10, excludeIgnored: $excludeIgnored, sortOrder: $sortOrder, sortBy: $sortBy}) @skip(if: $hasComment) {
|
||||
nodes {
|
||||
...CoralEmbedStream_Stream_comment
|
||||
}
|
||||
|
||||
+11
-11
@@ -189,11 +189,11 @@ const getEndCursor = (ctx, nodes, {cursor, sortBy}) => {
|
||||
* @param {Object} query the current mongoose query object
|
||||
* @param {Object} params the params from the client describing the query
|
||||
*/
|
||||
const applySort = (ctx, query, {cursor, sort, sortBy}) => {
|
||||
const applySort = (ctx, query, {cursor, sortOrder, sortBy}) => {
|
||||
switch (sortBy) {
|
||||
case 'CREATED_AT': {
|
||||
if (cursor) {
|
||||
if (sort === 'DESC') {
|
||||
if (sortOrder === 'DESC') {
|
||||
query = query.where({
|
||||
created_at: {
|
||||
$lt: cursor,
|
||||
@@ -208,14 +208,14 @@ const applySort = (ctx, query, {cursor, sort, sortBy}) => {
|
||||
}
|
||||
}
|
||||
|
||||
return query.sort({created_at: sort === 'DESC' ? -1 : 1});
|
||||
return query.sort({created_at: sortOrder === 'DESC' ? -1 : 1});
|
||||
}
|
||||
case 'REPLIES': {
|
||||
if (cursor) {
|
||||
query = query.skip(cursor);
|
||||
}
|
||||
|
||||
return query.sort({reply_count: sort === 'DESC' ? -1 : 1, created_at: sort === 'DESC' ? -1 : 1});
|
||||
return query.sort({reply_count: sortOrder === 'DESC' ? -1 : 1, created_at: sortOrder === 'DESC' ? -1 : 1});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ const applySort = (ctx, query, {cursor, sort, sortBy}) => {
|
||||
throw new Error(`unable to sort by ${sortBy}, no plugin was provided to handle this type`);
|
||||
}
|
||||
|
||||
return ctx.plugins.Sort.Comments[SORT_KEY].sort(ctx, query, {cursor, sort});
|
||||
return ctx.plugins.Sort.Comments[SORT_KEY].sort(ctx, query, {cursor, sortOrder});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -236,10 +236,10 @@ const applySort = (ctx, query, {cursor, sort, sortBy}) => {
|
||||
* @param {Object} query the current mongoose query object
|
||||
* @param {Object} params the params from the client describing the query
|
||||
*/
|
||||
const executeWithSort = async (ctx, query, {cursor, sort, sortBy, limit}) => {
|
||||
const executeWithSort = async (ctx, query, {cursor, sortOrder, sortBy, limit}) => {
|
||||
|
||||
// Apply the sort to the query.
|
||||
query = applySort(ctx, query, {cursor, sort, sortBy});
|
||||
query = applySort(ctx, query, {cursor, sortOrder, sortBy});
|
||||
|
||||
// Apply the limit (if it exists, as it's applied universally).
|
||||
if (limit) {
|
||||
@@ -263,8 +263,8 @@ const executeWithSort = async (ctx, query, {cursor, sort, sortBy, limit}) => {
|
||||
// Use the generator functions below to extract the cursor details based on
|
||||
// the current sortBy parameter.
|
||||
return {
|
||||
startCursor: getStartCursor(ctx, nodes, {cursor, sort, sortBy, limit}),
|
||||
endCursor: getEndCursor(ctx, nodes, {cursor, sort, sortBy, limit}),
|
||||
startCursor: getStartCursor(ctx, nodes, {cursor, sortOrder, sortBy, limit}),
|
||||
endCursor: getEndCursor(ctx, nodes, {cursor, sortOrder, sortBy, limit}),
|
||||
hasNextPage,
|
||||
nodes,
|
||||
};
|
||||
@@ -277,7 +277,7 @@ const executeWithSort = async (ctx, query, {cursor, sort, sortBy, limit}) => {
|
||||
* @param {Object} context graph context
|
||||
* @param {Object} query query terms to apply to the comments query
|
||||
*/
|
||||
const getCommentsByQuery = async (ctx, {ids, statuses, asset_id, parent_id, author_id, limit, cursor, sort, sortBy, excludeIgnored, tags, action_type}) => {
|
||||
const getCommentsByQuery = async (ctx, {ids, statuses, asset_id, parent_id, author_id, limit, cursor, sortOrder, sortBy, excludeIgnored, tags, action_type}) => {
|
||||
let comments = CommentModel.find();
|
||||
|
||||
// Only administrators can search for comments with statuses that are not
|
||||
@@ -343,7 +343,7 @@ const getCommentsByQuery = async (ctx, {ids, statuses, asset_id, parent_id, auth
|
||||
});
|
||||
}
|
||||
|
||||
return executeWithSort(ctx, comments, {cursor, sort, sortBy, limit});
|
||||
return executeWithSort(ctx, comments, {cursor, sortOrder, sortBy, limit});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+12
-12
@@ -54,13 +54,13 @@ const getAssetActivityMetrics = ({loaders: {Assets}}, {from, to, limit}) => {
|
||||
/**
|
||||
* Returns a list of assets with action metadata included on the models.
|
||||
*/
|
||||
const getAssetMetrics = async ({loaders: {Metrics, Assets, Comments}}, {from, to, sort, limit}) => {
|
||||
const getAssetMetrics = async ({loaders: {Metrics, Assets, Comments}}, {from, to, sortBy, limit}) => {
|
||||
|
||||
// Get the recent actions.
|
||||
let actionSummaries = await Metrics.getRecentActions.load({from, to});
|
||||
|
||||
let commentMetrics = actionSummaries.reduce((acc, {item_id, action_type, count}) => {
|
||||
if (action_type !== sort) {
|
||||
if (action_type !== sortBy) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
@@ -94,9 +94,9 @@ const getAssetMetrics = async ({loaders: {Metrics, Assets, Comments}}, {from, to
|
||||
|
||||
return {action_summaries, id: asset_id};
|
||||
})
|
||||
|
||||
|
||||
.filter((asset) => {
|
||||
let contextActionSummary = asset.action_summaries.find((({action_type}) => action_type === sort));
|
||||
let contextActionSummary = asset.action_summaries.find((({action_type}) => action_type === sortBy));
|
||||
if (contextActionSummary === null || contextActionSummary.actionCount === 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -108,8 +108,8 @@ const getAssetMetrics = async ({loaders: {Metrics, Assets, Comments}}, {from, to
|
||||
// if the action summary does not exist on the object, that it is less
|
||||
// prefered over the one that does have it.
|
||||
.sort((a, b) => {
|
||||
let aActionSummary = a.action_summaries.find((({action_type}) => action_type === sort));
|
||||
let bActionSummary = b.action_summaries.find((({action_type}) => action_type === sort));
|
||||
let aActionSummary = a.action_summaries.find((({action_type}) => action_type === sortBy));
|
||||
let bActionSummary = b.action_summaries.find((({action_type}) => action_type === sortBy));
|
||||
|
||||
// Both of them had an actionCount, hence we can determine that we could
|
||||
// compare the actual values directly.
|
||||
@@ -144,15 +144,15 @@ const getAssetMetrics = async ({loaders: {Metrics, Assets, Comments}}, {from, to
|
||||
* Returns a list of comments that are retrieved based on most activity within
|
||||
* the indicated time range.
|
||||
*/
|
||||
const getCommentMetrics = async ({loaders: {Metrics, Comments}}, {from, to, sort, limit}) => {
|
||||
const getCommentMetrics = async ({loaders: {Metrics, Comments}}, {from, to, sortBy, limit}) => {
|
||||
|
||||
let commentActionSummaries = {};
|
||||
|
||||
let actionSummaries = await Metrics.getRecentActions.load({from, to});
|
||||
|
||||
actionSummaries.sort((a, b) => {
|
||||
let aActionSummary = a.action_type === sort ? a : null;
|
||||
let bActionSummary = b.action_type === sort ? b : null;
|
||||
let aActionSummary = a.action_type === sortBy ? a : null;
|
||||
let bActionSummary = b.action_type === sortBy ? b : null;
|
||||
|
||||
// If either a or b don't have this action type, then one of them will
|
||||
// automatically win.
|
||||
@@ -178,7 +178,7 @@ const getCommentMetrics = async ({loaders: {Metrics, Comments}}, {from, to, sort
|
||||
// Grab the comment id's for comment where they have at least one of the
|
||||
// actions being sorted by.
|
||||
let commentIDs = Object.keys(commentActionSummaries).filter((item_id) => {
|
||||
let contextActionSummary = commentActionSummaries[item_id].find(({action_type}) => action_type === sort);
|
||||
let contextActionSummary = commentActionSummaries[item_id].find(({action_type}) => action_type === sortBy);
|
||||
if (contextActionSummary == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -247,11 +247,11 @@ module.exports = (context) => ({
|
||||
cacheKeyFn: objectCacheKeyFn('from', 'to')
|
||||
}),
|
||||
Assets: {
|
||||
get: ({from, to, sort, limit}) => getAssetMetrics(context, {from, to, sort, limit}),
|
||||
get: ({from, to, sortBy, limit}) => getAssetMetrics(context, {from, to, sortBy, limit}),
|
||||
getActivity: ({from, to, limit}) => getAssetActivityMetrics(context, {from, to, limit}),
|
||||
},
|
||||
Comments: {
|
||||
get: ({from, to, sort, limit}) => getCommentMetrics(context, {from, to, sort, limit}),
|
||||
get: ({from, to, sortBy, limit}) => getCommentMetrics(context, {from, to, sortBy, limit}),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ const genUserByIDs = (context, ids) => UsersService
|
||||
* @param {Object} context graph context
|
||||
* @param {Object} query query terms to apply to the users query
|
||||
*/
|
||||
const getUsersByQuery = ({user}, {ids, limit, cursor, statuses = null, sort}) => {
|
||||
const getUsersByQuery = ({user}, {ids, limit, cursor, statuses = null, sortOrder}) => {
|
||||
|
||||
let users = UserModel.find();
|
||||
|
||||
@@ -36,7 +36,7 @@ const getUsersByQuery = ({user}, {ids, limit, cursor, statuses = null, sort}) =>
|
||||
}
|
||||
|
||||
if (cursor) {
|
||||
if (sort === 'DESC') {
|
||||
if (sortOrder === 'DESC') {
|
||||
users = users.where({
|
||||
created_at: {
|
||||
$lt: cursor
|
||||
@@ -52,7 +52,7 @@ const getUsersByQuery = ({user}, {ids, limit, cursor, statuses = null, sort}) =>
|
||||
}
|
||||
|
||||
return users
|
||||
.sort({created_at: sort === 'DESC' ? -1 : 1})
|
||||
.sort({created_at: sortOrder === 'DESC' ? -1 : 1})
|
||||
.limit(limit);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const Comment = {
|
||||
user({author_id}, _, {loaders: {Users}}) {
|
||||
return Users.getByID.load(author_id);
|
||||
},
|
||||
replies({id, asset_id, reply_count}, {query: {sort, sortBy, limit, excludeIgnored}}, {loaders: {Comments}}) {
|
||||
replies({id, asset_id, reply_count}, {query}, {loaders: {Comments}}) {
|
||||
|
||||
// Don't bother looking up replies if there aren't any there!
|
||||
if (reply_count === 0) {
|
||||
@@ -24,14 +24,10 @@ const Comment = {
|
||||
};
|
||||
}
|
||||
|
||||
return Comments.getByQuery({
|
||||
asset_id,
|
||||
parent_id: id,
|
||||
sort,
|
||||
sortBy,
|
||||
limit,
|
||||
excludeIgnored,
|
||||
});
|
||||
query.asset_id = asset_id;
|
||||
query.parent_id = id;
|
||||
|
||||
return Comments.getByQuery(query);
|
||||
},
|
||||
replyCount({reply_count}) {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ const {SEARCH_OTHER_USERS} = require('../../perms/constants');
|
||||
|
||||
const CommentStatusHistory = {
|
||||
assigned_by({assigned_by}, _, {user, loaders: {Users}}) {
|
||||
if (!user || !user.can(SEARCH_OTHER_USERS) || assigned_by != null) {
|
||||
if (!user || !user.can(SEARCH_OTHER_USERS) || assigned_by == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,24 +50,25 @@ const RootQuery = {
|
||||
return Comments.getCountByQuery(query);
|
||||
},
|
||||
|
||||
assetMetrics(_, {from, to, sort, limit = 10}, {user, loaders: {Metrics: {Assets}}}) {
|
||||
assetMetrics(_, query, {user, loaders: {Metrics: {Assets}}}) {
|
||||
if (user == null || !user.can(SEARCH_ASSETS)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (sort === 'ACTIVITY') {
|
||||
return Assets.getActivity({from, to, limit});
|
||||
const {sortBy} = query;
|
||||
if (sortBy === 'ACTIVITY') {
|
||||
return Assets.getActivity(query);
|
||||
}
|
||||
|
||||
return Assets.get({from, to, sort, limit});
|
||||
return Assets.get(query);
|
||||
},
|
||||
|
||||
commentMetrics(_, {from, to, sort, limit = 10}, {user, loaders: {Metrics: {Comments}}}) {
|
||||
commentMetrics(_, query, {user, loaders: {Metrics: {Comments}}}) {
|
||||
if (user == null || !user.can(SEARCH_COMMENT_METRICS)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Comments.get({from, to, sort, limit});
|
||||
return Comments.get(query);
|
||||
},
|
||||
|
||||
// This returns the current user, ensure that if we aren't logged in, we
|
||||
@@ -97,7 +98,6 @@ const RootQuery = {
|
||||
}
|
||||
|
||||
const {action_type} = query;
|
||||
|
||||
if (action_type) {
|
||||
query.ids = await Actions.getByTypes({action_type, item_type: 'USERS'});
|
||||
query.statuses = ['PENDING'];
|
||||
|
||||
@@ -132,7 +132,7 @@ input UsersQuery {
|
||||
cursor: Cursor
|
||||
|
||||
# Sort the results by created_at.
|
||||
sort: SORT_ORDER = DESC
|
||||
sortOrder: SORT_ORDER = DESC
|
||||
}
|
||||
|
||||
# AssetsQuery allows teh ability to query assets by specific fields
|
||||
@@ -247,7 +247,7 @@ input CommentsQuery {
|
||||
cursor: Cursor
|
||||
|
||||
# Sort the results by from largest first.
|
||||
sort: SORT_ORDER = DESC
|
||||
sortOrder: SORT_ORDER = DESC
|
||||
|
||||
# The order to sort the comments by, sorting by default the created at
|
||||
# timestamp.
|
||||
@@ -263,7 +263,7 @@ input CommentsQuery {
|
||||
input RepliesQuery {
|
||||
|
||||
# Sort the results by from smallest first.
|
||||
sort: SORT_ORDER = ASC
|
||||
sortOrder: SORT_ORDER = ASC
|
||||
|
||||
# The order to sort the comments by, sorting by default the created at
|
||||
# timestamp.
|
||||
@@ -737,11 +737,11 @@ type RootQuery {
|
||||
|
||||
# Asset metrics related to user actions are saturated into the assets
|
||||
# returned. Parameters `from` and `to` are related to the action created_at field.
|
||||
assetMetrics(from: Date!, to: Date!, sort: ASSET_METRICS_SORT!, limit: Int = 10): [Asset!]
|
||||
assetMetrics(from: Date!, to: Date!, sortBy: ASSET_METRICS_SORT!, limit: Int = 10): [Asset!]
|
||||
|
||||
# Comment metrics related to user actions are saturated into the comments
|
||||
# returned. Parameters `from` and `to` are related to the action created_at field.
|
||||
commentMetrics(from: Date!, to: Date!, sort: ACTION_TYPE!, limit: Int = 10): [Comment!]
|
||||
commentMetrics(from: Date!, to: Date!, sortBy: ACTION_TYPE!, limit: Int = 10): [Comment!]
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -129,12 +129,12 @@ function getReactionConfig(reaction) {
|
||||
endCursor(ctx, nodes, {cursor}) {
|
||||
return nodes.length ? (cursor != null ? cursor : 0) + nodes.length : null;
|
||||
},
|
||||
sort(ctx, query, {cursor, sort}) {
|
||||
sort(ctx, query, {cursor, sortOrder}) {
|
||||
if (cursor) {
|
||||
query = query.skip(cursor);
|
||||
}
|
||||
|
||||
return query.sort({[`action_counts.${reaction}`]: sort === 'DESC' ? -1 : 1, created_at: sort === 'DESC' ? -1 : 1});
|
||||
return query.sort({[`action_counts.${reaction}`]: sortOrder === 'DESC' ? -1 : 1, created_at: sortOrder === 'DESC' ? -1 : 1});
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -62,7 +62,7 @@ const LOAD_MORE_QUERY = gql`
|
||||
cursor: $cursor
|
||||
tags: ["FEATURED"]
|
||||
asset_id: $asset_id,
|
||||
sort: $sortOrder
|
||||
sortOrder: $sortOrder
|
||||
sortBy: $sortBy
|
||||
excludeIgnored: $excludeIgnored
|
||||
}
|
||||
@@ -100,7 +100,7 @@ const enhance = compose(
|
||||
featuredComments: comments(
|
||||
query: {
|
||||
tags: ["FEATURED"]
|
||||
sort: $sortOrder
|
||||
sortOrder: $sortOrder
|
||||
sortBy: $sortBy
|
||||
}
|
||||
deep: true
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('graph.loaders.Metrics', () => {
|
||||
describe('#Comments', () => {
|
||||
const query = `
|
||||
query CommentMetrics($from: Date!, $to: Date!) {
|
||||
flagged: commentMetrics(from: $from, to: $to, sort: FLAG) {
|
||||
flagged: commentMetrics(from: $from, to: $to, sortBy: FLAG) {
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -24,11 +24,11 @@ describe('graph.loaders.Metrics', () => {
|
||||
|
||||
describe('different comment states', () => {
|
||||
|
||||
beforeEach(() =>[
|
||||
CommentModel.create({id: '1', body: 'a new comment!'}),
|
||||
CommentModel.create({id: '2', body: 'a new comment!'}),
|
||||
CommentModel.create({id: '3', body: 'a new comment!'})
|
||||
]);
|
||||
beforeEach(() => CommentModel.create([
|
||||
{id: '1', body: 'a new comment!'},
|
||||
{id: '2', body: 'a new comment!'},
|
||||
{id: '3', body: 'a new comment!'}
|
||||
]));
|
||||
|
||||
[
|
||||
{flagged: 0, actions: []},
|
||||
@@ -76,7 +76,7 @@ describe('graph.loaders.Metrics', () => {
|
||||
}
|
||||
|
||||
query Metrics($from: Date!, $to: Date!) {
|
||||
assetsByFlag: assetMetrics(from: $from, to: $to, sort: FLAG) {
|
||||
assetsByFlag: assetMetrics(from: $from, to: $to, sortBy: FLAG) {
|
||||
...metrics
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user