<commit_before>import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { fetchMobilizations, isMobilizationsLoaded } from './../../reducers/mobilizations'
import { findBlocks, isBlocksLoaded } from './../../reducers/blocks'
import { findWidgets, isWidgetsLoaded } from './../../reducers/widgets'
import { ShowMobilization } from './../'
import ga from 'react-ga'

const mapStateToProps = (state) => {
  return ({
    mobilizations: state.mobilizations,
    blocks: state.blocks,
    widgets: state.widgets
  })
}

export class CustomDomainWrapper extends React.Component {
  static propTypes = {
    mobilizations: PropTypes.object.isRequired,
    blocks: PropTypes.object.isRequired,
    widgets: PropTypes.object.isRequired,
    params: PropTypes.object
  }

  static fetchData(store, params, query, host) {
    const regex = host.match(`(.+)\.${process.env.APP_DOMAIN}`)
    let findParams

    if (regex) {
      findParams = { slug: regex[1] }
    } else {
      findParams = { custom_domain: host }
    }

    const promises = []

    if (!isMobilizationsLoaded(store.getState())) {
      const action = fetchMobilizations(findParams)
      const dispatch = store.dispatch(action)
      promises.push(dispatch)
    }

    if (!isBlocksLoaded(store.getState())) {
      const action = findBlocks(findParams)
      const promise = store.dispatch(action)
      promises.push(promise)
    }

    if (!isWidgetsLoaded(store.getState())) {
      const action = findWidgets(findParams)
      const promise = store.dispatch(action)
      promises.push(promise)
    }

    return Promise.all(promises)
  }

  componentDidMount() {
    ga.initialize('UA-26278513-30', { debug: true })
    ga.pageview(document.location.pathname)
  }

  renderMobilization() {
    const { mobilizations, blocks, widgets } = this.props

    return (
      <ShowMobilization
        mobilization={mobilizations.data[0]}
        blocks={blocks}
        widgets={widgets}
        {...this.props}
      />
    )
  }

  renderMobilizationNotFound() {
    return (
      <div className='absolute top-0 bottom-0 left-0 right-0 flex flex-center bg-gray'>
        <div className='center flex-auto white'>
          <div className='h1'>Ops! Estamos com um problema técnico. Em caso de dúvida, escreva para <a href="mailto:<EMAIL>"><EMAIL></a>.</div><commit_msg>[#114472007] remove initial tests with react-ga<commit_after>import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { fetchMobilizations, isMobilizationsLoaded } from './../../reducers/mobilizations'
import { findBlocks, isBlocksLoaded } from './../../reducers/blocks'
import { findWidgets, isWidgetsLoaded } from './../../reducers/widgets'
import { ShowMobilization } from './../'

const mapStateToProps = (state) => {
  return ({
    mobilizations: state.mobilizations,
    blocks: state.blocks,
    widgets: state.widgets
  })
}

export class CustomDomainWrapper extends React.Component {
  static propTypes = {
    mobilizations: PropTypes.object.isRequired,
    blocks: PropTypes.object.isRequired,
    widgets: PropTypes.object.isRequired,
    params: PropTypes.object
  }

  static fetchData(store, params, query, host) {
    const regex = host.match(`(.+)\.${process.env.APP_DOMAIN}`)
    let findParams

    if (regex) {
      findParams = { slug: regex[1] }
    } else {
      findParams = { custom_domain: host }
    }

    const promises = []

    if (!isMobilizationsLoaded(store.getState())) {
      const action = fetchMobilizations(findParams)
      const dispatch = store.dispatch(action)
      promises.push(dispatch)
    }

    if (!isBlocksLoaded(store.getState())) {
      const action = findBlocks(findParams)
      const promise = store.dispatch(action)
      promises.push(promise)
    }

    if (!isWidgetsLoaded(store.getState())) {
      const action = findWidgets(findParams)
      const promise = store.dispatch(action)
      promises.push(promise)
    }

    return Promise.all(promises)
  }

  renderMobilization() {
    const { mobilizations, blocks, widgets } = this.props

    return (
      <ShowMobilization
        mobilization={mobilizations.data[0]}
        blocks={blocks}
        widgets={widgets}
        {...this.props}
      />
    )
  }

  renderMobilizationNotFound() {
    return (
      <div className='absolute top-0 bottom-0 left-0 right-0 flex flex-center bg-gray'>
        <div className='center flex-auto white'>
          <div className='h1'>Ops! Estamos com um problema técnico. Em caso de dúvida, escreva para <a href="mailto:<EMAIL>"><EMAIL></a>.</div>
{'fraction_non_alphanumeric': 0.13070900391474555, 'fraction_numerical': 0.007177033492822967, 'mean_word_length': 3.0989304812834226, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '1562864', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1387, 'n_words': 301}