<commit_before>import graphFetcher from '../utils/graphFetcher';
import store from '../utils/store';
import { RECEIVE_ENTRIES } from './entryActions';
import { RECEIVE_SECTIONS } from './sectionActions';
import { RECEIVE_FIELDS } from './fieldActions';
import { RECEIVE_USER, RECEIVE_USERS } from './userActions';
import { RECEIVE_USERGROUPS } from './usergroupActions';
import { RECEIVE_ASSETS } from './assetActions';

const query = `{
  entries {
    _id
    title
    slug
    author
    dateCreated
    section
    status
  }

  fields {
    _id
    title
    instructions
    type
    dateCreated
    slug
    handle
  }

  sections {
    _id
    template
    title
    slug
    fields
    dateCreated
  }

  user {
    _id
    username
    name {
      first
      last
    }
    dateCreated
    image
  }

  users {
    _id
    username
    name {
      first
      last
    }
    dateCreated
    image
  }

  usergroups {
    _id
    title
    slug
    dateCreated
    permissions {
      sections {
        canAddSections
        canDeleteSections
        canEditSections
      }
      fields {
        canAddFields
        canDeleteFields
        canEditFields
      }
      entries {
        canAddEntries
        canDeleteEntries
        canOnlyEditOwnEntries
        canEditLive
        canEditDrafts
        canSeeDrafts
        canChangeEntryStatus
      }
      users {
        canManageUsers
        canManageUserGroups
      }
    }
  }
}`;

export default async function bigFetch() {
  const { dispatch } = store;
  const { data, errors } = await graphFetcher(query);

  if (errors) throw new Error('Error!', errors);

  const { sections, assets, entries, fields, user, users, usergroups } = data.data;
  const dispatchers = [
    { type: RECEIVE_SECTIONS, sections },
    { type: RECEIVE_ASSETS, assets },
    { type: RECEIVE_ENTRIES, entries },
    { type: RECEIVE_FIELDS, fields },
    { type: RECEIVE_USER, user },
    { type: RECEIVE_USERS, users },
    { type: RECEIVE_USERGROUPS, usergroups },
  ];

  const receivedAt = Date.now();
  dispatchers.forEach(obj => dispatch({ ...obj, receivedAt }));
}<commit_msg>:lock: Fix logged out redirect<commit_after>import { push } from 'react-router-redux';
import graphFetcher from '../utils/graphFetcher';
import store from '../utils/store';
import { RECEIVE_ENTRIES } from './entryActions';
import { RECEIVE_SECTIONS } from './sectionActions';
import { RECEIVE_FIELDS } from './fieldActions';
import { RECEIVE_USER, RECEIVE_USERS } from './userActions';
import { RECEIVE_USERGROUPS } from './usergroupActions';
import { RECEIVE_ASSETS } from './assetActions';

const query = `{
  entries {
    _id
    title
    slug
    author
    dateCreated
    section
    status
  }

  fields {
    _id
    title
    instructions
    type
    dateCreated
    slug
    handle
  }

  sections {
    _id
    template
    title
    slug
    fields
    dateCreated
  }

  user {
    _id
    username
    name {
      first
      last
    }
    dateCreated
    image
  }

  users {
    _id
    username
    name {
      first
      last
    }
    dateCreated
    image
  }

  usergroups {
    _id
    title
    slug
    dateCreated
    permissions {
      sections {
        canAddSections
        canDeleteSections
        canEditSections
      }
      fields {
        canAddFields
        canDeleteFields
        canEditFields
      }
      entries {
        canAddEntries
        canDeleteEntries
        canOnlyEditOwnEntries
        canEditLive
        canEditDrafts
        canSeeDrafts
        canChangeEntryStatus
      }
      users {
        canManageUsers
        canManageUserGroups
      }
    }
  }
}`;

export default async function bigFetch() {
  const { dispatch } = store;
  const { data, errors } = await graphFetcher(query);

  if (data.status === 401) dispatch(push(data.redirect));
  if (errors) throw new Error('Error!', errors);

  const { sections, assets, entries, fields, user, users, usergroups } = data.data;
  const dispatchers = [
    { type: RECEIVE_SECTIONS, sections },
    { type: RECEIVE_ASSETS, assets },
    { type: RECEIVE_ENTRIES, entries },
    { type: RECEIVE_FIELDS, fields },
    { type: RECEIVE_USER, user },
    { type: RECEIVE_USERS, users },
    { type: RECEIVE_USERGROUPS, usergroups },
  ];

  const receivedAt = Date.now();
  dispatchers.forEach(obj => dispatch({ ...obj, receivedAt }));
}
{'fraction_non_alphanumeric': 0.08902550091074682, 'fraction_numerical': 0.0006830601092896175, 'mean_word_length': 2.1972343522561864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3480623', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1370, 'n_words': 326}