<commit_before>// @flow
import React from 'react';
import Page from 'component/page';
import CategoryList from 'component/categoryList';

type Props = {
  fetchFeaturedUris: () => void,
  fetchingFeaturedUris: boolean,
  featuredUris: {},
};

class DiscoverPage extends React.PureComponent<Props> {
  componentWillMount() {
    this.props.fetchFeaturedUris();
  }

  render() {
    const { featuredUris, fetchingFeaturedUris } = this.props;
    const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length;
    const failedToLoad = !fetchingFeaturedUris && !hasContent;

    return (
      <Page noPadding isLoading={!hasContent && fetchingFeaturedUris}>
        {hasContent &&
          Object.keys(featuredUris).map(
            category =>
              featuredUris[category].length ? (
                <CategoryList key={category} category={category} names={featuredUris[category]} />
              ) : (
                <CategoryList
                  key={category}
                  category={category.split('#')[0]}
                  categoryLink={category}
                />
              )
          )}
        {failedToLoad && <div className="empty">{__('Failed to load landing content.')}</div>}
      </Page>
    );
  }
}

export default DiscoverPage;<commit_msg>set 1hr interval on fetchFeaturedUris<commit_after>// @flow
import React from 'react';
import Page from 'component/page';
import CategoryList from 'component/categoryList';

type Props = {
  fetchFeaturedUris: () => void,
  fetchingFeaturedUris: boolean,
  featuredUris: {},
};

class DiscoverPage extends React.PureComponent<Props> {
  constructor() {
    super();
    this.continousFetch = undefined;
  }

  componentWillMount() {
    const { fetchFeaturedUris } = this.props;
    fetchFeaturedUris();
    this.continousFetch = setInterval(fetchFeaturedUris, 1000 * 60 * 60);
  }

  componentWillUnmount() {
    this.clearContinuousFetch();
  }

  clearContinuousFetch() {
    if (this.continousFetch) {
      clearInterval(this.continousFetch);
      this.continousFetch = null;
    }
  }

  continousFetch: ?number;

  render() {
    const { featuredUris, fetchingFeaturedUris } = this.props;
    const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length;
    const failedToLoad = !fetchingFeaturedUris && !hasContent;

    return (
      <Page noPadding isLoading={!hasContent && fetchingFeaturedUris}>
        {hasContent &&
          Object.keys(featuredUris).map(
            category =>
              featuredUris[category].length ? (
                <CategoryList key={category} category={category} names={featuredUris[category]} />
              ) : (
                <CategoryList
                  key={category}
                  category={category.split('#')[0]}
                  categoryLink={category}
                />
              )
          )}
        {failedToLoad && <div className="empty">{__('Failed to load landing content.')}</div>}
      </Page>
    );
  }
}

export default DiscoverPage;
{'fraction_non_alphanumeric': 0.1237721021611002, 'fraction_numerical': 0.003601833660772757, 'mean_word_length': 2.611111111111111, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '3380883', 'n_tokens_mistral': 888, 'n_tokens_neox': 855, 'n_words': 165}