<commit_before>/*global config*/
import Reflux from 'reflux';
import BranchActions from '../actions/branchActions';
import BranchApi from '../data/BranchApi';

const BranchStore = Reflux.createStore({

  listenables: BranchActions,

  init() {  
    this.branchBuildHistory = [];
    this.shouldPoll = true;
  },

  onLoadBranchBuildHistory(params) {
    this.params = params;

    BranchApi.fetchBranchBuildHistory(params, (resp) => {
      this.branchBuildHistory = resp;

      this.trigger({
        builds: this.branchBuildHistory,
        loadingBranches: false
      });
    });
  },

  onLoadBranchInfo(params) {
    this.params = params;

    BranchApi.fetchBranchInfo(params, (resp) => {
      this.branchInfo = resp;

      this.trigger({
        branchInfo: this.branchInfo,
        loadingBranchInfo: false
      });
    });
  },

  onLoadBranchModules(params) {
    this.params = params;

    BranchApi.fetchBranchModules(params, (resp) => {
      this.modules = resp;

      this.trigger({
        modules: this.modules,
        loadingModules: false
      });
    });
  },

  onLoadMalformedFiles(params) {
    this.params = params;

    BranchApi.fetchMalformedFiles(params, (resp) => {
      this.malformedFiles = resp;

      this.trigger({
        malformedFiles: this.malformedFiles,
        loadingMalformedFiles: false
      });
    });
  },

  onStartPolling(params) {
    this.params = params;
    this.shouldPoll = true;
    this._poll();
  },

  onStopPolling() {
    this.shouldPoll = false;
  },

  onTriggerBuild(params, state) {
    const {selectedModules, buildDownstreamModules, resetCache} = state;

    BranchApi.triggerBuild(params, selectedModules, buildDownstreamModules, resetCache, (error, resp) => {
      if (error) {
        this.error = error;
        return this.triggerErrorUpdate();
      }
    });
  },

  triggerErrorUpdate() {
    this.trigger({
      error: this.error,
      loadingBranches: false
    });

    this.error = undefined;
  },

  _poll() {
    this.onLoadBranchBuildHistory(this.params);

    if (this.shouldPoll) {
      setTimeout(this._poll, config.buildsRefresh);
    }
  }

});

export default BranchStore;
<commit_msg>immediately poll after triggering build<commit_after>/*global config*/
import Reflux from 'reflux';
import BranchActions from '../actions/branchActions';
import BranchApi from '../data/BranchApi';

const BranchStore = Reflux.createStore({

  listenables: BranchActions,

  init() {  
    this.branchBuildHistory = [];
    this.shouldPoll = true;
  },

  onLoadBranchBuildHistory(params) {
    this.params = params;

    BranchApi.fetchBranchBuildHistory(params, (resp) => {
      this.branchBuildHistory = resp;

      this.trigger({
        builds: this.branchBuildHistory,
        loadingBranches: false
      });
    });
  },

  onLoadBranchInfo(params) {
    this.params = params;

    BranchApi.fetchBranchInfo(params, (resp) => {
      this.branchInfo = resp;

      this.trigger({
        branchInfo: this.branchInfo,
        loadingBranchInfo: false
      });
    });
  },

  onLoadBranchModules(params) {
    this.params = params;

    BranchApi.fetchBranchModules(params, (resp) => {
      this.modules = resp;

      this.trigger({
        modules: this.modules,
        loadingModules: false
      });
    });
  },

  onLoadMalformedFiles(params) {
    this.params = params;

    BranchApi.fetchMalformedFiles(params, (resp) => {
      this.malformedFiles = resp;

      this.trigger({
        malformedFiles: this.malformedFiles,
        loadingMalformedFiles: false
      });
    });
  },

  onStartPolling(params) {
    this.params = params;
    this.shouldPoll = true;
    this._poll();
  },

  onStopPolling() {
    this.shouldPoll = false;
  },

  onTriggerBuild(params, state) {
    const {selectedModules, buildDownstreamModules, resetCache} = state;

    BranchApi.triggerBuild(params, selectedModules, buildDownstreamModules, resetCache, (error, resp) => {
      if (error) {
        this.error = error;
        return this.triggerErrorUpdate();
      }

      this.onLoadBranchBuildHistory(params);
    });
  },

  triggerErrorUpdate() {
    this.trigger({
      error: this.error,
      loadingBranches: false
    });

    this.error = undefined;
  },

  _poll() {
    this.onLoadBranchBuildHistory(this.params);

    if (this.shouldPoll) {
      setTimeout(this._poll, config.buildsRefresh);
    }
  }

});

export default BranchStore;

{'fraction_non_alphanumeric': 0.12404494382022471, 'fraction_numerical': 0.0, 'mean_word_length': 2.7529510961214165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '7138424', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1360, 'n_words': 237}