<commit_before>import {
  GraphQLID,
  GraphQLInt,
  GraphQLObjectType,
  GraphQLString,
  GraphQLNonNull,
  GraphQLList,
} from 'graphql';
import Node from '../interfaces/Node';

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

const Analytics = new GraphQLObjectType({
  name: 'Analytics',
  interfaces: [Node],
  fields: () => ({
    id: { type: new GraphQLNonNull(GraphQLID) },
    docId: {
      type: new GraphQLNonNull(GraphQLID),
      description:
        'The id for the document that this analytic datapoint is for.',
    },
    type: {
      type: new GraphQLNonNull(AnalyticsDocTypeEnum),
      description: 'Type of document that this analytic datapoint is for.',
    },
    date: {
      type: new GraphQLNonNull(GraphQLString),
      description:
        'The day this analytic datapoint is represented, in YYYY-MM-DD format',
    },
    lineUser: {
      type: new GraphQLNonNull(GraphQLInt),
      resolve: ({ stats }) => stats.lineUser ?? 0,
    },
    lineVisit: {
      type: new GraphQLNonNull(GraphQLInt),
      resolve: ({ stats }) => stats.lineVisit ?? 0,
    },
    webUser: {
      type: new GraphQLNonNull(GraphQLInt),
      resolve: ({ stats }) => stats.webUser ?? 0,
    },
    webVisit: {
      type: new GraphQLNonNull(GraphQLInt),
      resolve: ({ stats }) => stats.webVisit ?? 0,
    },
    liffUser: {
      type: new GraphQLNonNull(GraphQLInt),
      description: 'Sum of LIFF visitor count from all sources',
      resolve({ stats }) {
        return (stats.liff ?? []).reduce(
          (sum, { user }) => sum + (user ?? 0),
          0
        );
      },
    },
    liffVisit: {<commit_msg>[Analytics] Don't touch existing stats field's nullness<commit_after>import {
  GraphQLID,
  GraphQLInt,
  GraphQLObjectType,
  GraphQLString,
  GraphQLNonNull,
  GraphQLList,
} from 'graphql';
import Node from '../interfaces/Node';

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

const Analytics = new GraphQLObjectType({
  name: 'Analytics',
  interfaces: [Node],
  fields: () => ({
    id: { type: new GraphQLNonNull(GraphQLID) },
    docId: {
      type: new GraphQLNonNull(GraphQLID),
      description:
        'The id for the document that this analytic datapoint is for.',
    },
    type: {
      type: new GraphQLNonNull(AnalyticsDocTypeEnum),
      description: 'Type of document that this analytic datapoint is for.',
    },
    date: {
      type: new GraphQLNonNull(GraphQLString),
      description:
        'The day this analytic datapoint is represented, in YYYY-MM-DD format',
    },
    lineUser: { type: GraphQLInt, resolve: ({ stats }) => stats.lineUser },
    lineVisit: { type: GraphQLInt, resolve: ({ stats }) => stats.lineVisit },
    webUser: { type: GraphQLInt, resolve: ({ stats }) => stats.webUser },
    webVisit: { type: GraphQLInt, resolve: ({ stats }) => stats.webVisit },
    liffUser: {
      type: new GraphQLNonNull(GraphQLInt),
      description: 'Sum of LIFF visitor count from all sources',
      resolve({ stats }) {
        return (stats.liff ?? []).reduce(
          (sum, { user }) => sum + (user ?? 0),
          0
        );
      },
    },
    liffVisit: {
{'fraction_non_alphanumeric': 0.12928921568627452, 'fraction_numerical': 0.0024509803921568627, 'mean_word_length': 2.863905325443787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6415569', 'n_tokens_mistral': 1011, 'n_tokens_neox': 999, 'n_words': 270}