From 86a6b545cc637cfcc9284281fadf17610374078a Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 28 Feb 2017 11:15:44 -0700 Subject: [PATCH] create a fragment for asset metrics. add some comments --- .../fragments/assetMetricsView.graphql | 12 ++++++ .../coral-admin/src/graphql/queries/index.js | 2 +- .../src/graphql/queries/metrics.graphql | 38 ------------------- .../src/graphql/queries/metricsQuery.graphql | 10 +++++ client/coral-admin/src/reducers/settings.js | 2 + 5 files changed, 25 insertions(+), 39 deletions(-) create mode 100644 client/coral-admin/src/graphql/fragments/assetMetricsView.graphql delete mode 100644 client/coral-admin/src/graphql/queries/metrics.graphql create mode 100644 client/coral-admin/src/graphql/queries/metricsQuery.graphql diff --git a/client/coral-admin/src/graphql/fragments/assetMetricsView.graphql b/client/coral-admin/src/graphql/fragments/assetMetricsView.graphql new file mode 100644 index 000000000..37335aeaa --- /dev/null +++ b/client/coral-admin/src/graphql/fragments/assetMetricsView.graphql @@ -0,0 +1,12 @@ +fragment metrics on Asset { + id + title + url + author + created_at + action_summaries { + type: __typename + actionCount + actionableItemCount + } +} diff --git a/client/coral-admin/src/graphql/queries/index.js b/client/coral-admin/src/graphql/queries/index.js index a2140a502..c4a30ad44 100644 --- a/client/coral-admin/src/graphql/queries/index.js +++ b/client/coral-admin/src/graphql/queries/index.js @@ -1,7 +1,7 @@ import {graphql} from 'react-apollo'; import MOD_QUEUE_QUERY from './modQueueQuery.graphql'; -import METRICS from './metrics.graphql'; +import METRICS from './metricsQuery.graphql'; export const modQueueQuery = graphql(MOD_QUEUE_QUERY, { options: ({params: {id = null}}) => { diff --git a/client/coral-admin/src/graphql/queries/metrics.graphql b/client/coral-admin/src/graphql/queries/metrics.graphql deleted file mode 100644 index 68de89cab..000000000 --- a/client/coral-admin/src/graphql/queries/metrics.graphql +++ /dev/null @@ -1,38 +0,0 @@ -fragment metrics on Asset { - id - title - url - author - created_at - action_summaries { - type: __typename - actionCount - actionableItemCount - } -} - -query Metrics ($from: Date!, $to: Date!) { - assetsByFlag: assetMetrics(from: $from, to: $to, sort: FLAG) { - ...metrics - } - assetsByLike: assetMetrics(from: $from, to: $to, sort: LIKE) { - ...metrics - } -# mostLikedComments: commentMetrics(from: $from, to: $to, sort: LIKE) { -# id -# body -# user { -# status -# username -# } -# asset { -# id -# title -# } -# created_at -# action_summaries { -# type: __typename -# count -# } -# } -} diff --git a/client/coral-admin/src/graphql/queries/metricsQuery.graphql b/client/coral-admin/src/graphql/queries/metricsQuery.graphql new file mode 100644 index 000000000..42a9fb70e --- /dev/null +++ b/client/coral-admin/src/graphql/queries/metricsQuery.graphql @@ -0,0 +1,10 @@ +#import "../fragments/assetMetricsView.graphql" + +query Metrics ($from: Date!, $to: Date!) { + assetsByFlag: assetMetrics(from: $from, to: $to, sort: FLAG) { + ...metrics + } + assetsByLike: assetMetrics(from: $from, to: $to, sort: LIKE) { + ...metrics + } +} diff --git a/client/coral-admin/src/reducers/settings.js b/client/coral-admin/src/reducers/settings.js index a6e0c9339..f74eb659f 100644 --- a/client/coral-admin/src/reducers/settings.js +++ b/client/coral-admin/src/reducers/settings.js @@ -4,6 +4,8 @@ import * as actions from '../actions/settings'; // this is initialized here because // currently you have to reload the dashboard to get new stats // cleaner updates are planned in the future. +// TODO: if there are more than two fields for the dashboard being created here, +// please create a new reducer specifically for the Dashboard. const DASHBOARD_WINDOW_MINUTES = 5; let then = new Date(); then.setMinutes(then.getMinutes() - DASHBOARD_WINDOW_MINUTES);