• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cofacts / rumors-api / 8974303076

06 May 2024 07:02PM UTC coverage: 88.312%. Remained the same
8974303076

push

github

web-flow
Merge pull request #336 from cofacts/typescript

Add Typescript support

771 of 931 branches covered (82.81%)

Branch coverage included in aggregate %.

1541 of 1687 relevant lines covered (91.35%)

22.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.42
/src/graphql/models/Analytics.js
1
import {
2
  GraphQLID,
3
  GraphQLInt,
4
  GraphQLObjectType,
5
  GraphQLString,
6
  GraphQLNonNull,
7
  GraphQLList,
8
} from 'graphql';
9
import Node from '../interfaces/Node';
10

11
import { createConnectionType } from 'graphql/util';
12
import AnalyticsDocTypeEnum from './AnalyticsDocTypeEnum';
13

14
const Analytics = new GraphQLObjectType({
36✔
15
  name: 'Analytics',
16
  interfaces: [Node],
17
  fields: () => ({
31✔
18
    id: { type: new GraphQLNonNull(GraphQLID) },
19
    docId: {
20
      type: new GraphQLNonNull(GraphQLID),
21
      description:
22
        'The id for the document that this analytic datapoint is for.',
23
    },
24
    type: {
25
      type: new GraphQLNonNull(AnalyticsDocTypeEnum),
26
      description: 'Type of document that this analytic datapoint is for.',
27
    },
28
    date: {
29
      type: new GraphQLNonNull(GraphQLString),
30
      description:
31
        'The day this analytic datapoint is represented, in YYYY-MM-DD format',
32
    },
33
    lineUser: { type: GraphQLInt, resolve: ({ stats }) => stats.lineUser },
6✔
34
    lineVisit: { type: GraphQLInt, resolve: ({ stats }) => stats.lineVisit },
6✔
35
    webUser: { type: GraphQLInt, resolve: ({ stats }) => stats.webUser },
6✔
36
    webVisit: { type: GraphQLInt, resolve: ({ stats }) => stats.webVisit },
6✔
37
    liffUser: {
38
      type: new GraphQLNonNull(GraphQLInt),
39
      description: 'Sum of LIFF visitor count from all sources',
40
      resolve({ stats }) {
41
        return (stats.liff ?? []).reduce(
1!
42
          (sum, { user }) => sum + (user ?? 0),
2!
43
          0
44
        );
45
      },
46
    },
47
    liffVisit: {
48
      type: new GraphQLNonNull(GraphQLInt),
49
      description: 'Sum of LIFF view count from all sources',
50
      resolve({ stats }) {
51
        return (stats.liff ?? []).reduce(
1!
52
          (sum, { visit }) => sum + (visit ?? 0),
2!
53
          0
54
        );
55
      },
56
    },
57
    liff: {
58
      type: new GraphQLNonNull(
59
        new GraphQLList(
60
          new GraphQLNonNull(
61
            new GraphQLObjectType({
62
              name: 'AnalyticsLiffEntry',
63
              fields: {
64
                source: {
65
                  description:
66
                    'utm_source for this LIFF stat entry. Empty string if not set.',
67
                  type: new GraphQLNonNull(GraphQLString),
68
                  resolve: ({ source }) => source ?? '',
2✔
69
                },
70
                user: {
71
                  type: new GraphQLNonNull(GraphQLInt),
72
                  resolve: ({ user }) => user ?? 0,
2!
73
                },
74
                visit: {
75
                  type: new GraphQLNonNull(GraphQLInt),
76
                  resolve: ({ visit }) => visit ?? 0,
2!
77
                },
78
              },
79
            })
80
          )
81
        )
82
      ),
83
      resolve: ({ stats }) => stats.liff ?? [],
1!
84
    },
85

86
    docUserId: {
87
      type: GraphQLID,
88
      description:
89
        'Author of the document that this analytic datapoint measures.',
90
    },
91
    docAppId: {
92
      type: GraphQLID,
93
      description:
94
        'Authoring app ID of the document that this analytic datapoint measures.',
95
    },
96
  }),
97
});
98

99
export default Analytics;
100

101
export const AnalyticsConnection = createConnectionType(
36✔
102
  'AnalyticsConnection',
103
  Analytics
104
);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc