<commit_before>import React from 'react'
import { connect } from 'react-redux'
import moment from 'moment'

import { editAlert, deleteAlert } from '../actions/alerts'
import { setVisibilitySearchText, setVisibilityFilter } from '../actions/visibilityFilter'

import AlertsList from '../components/AlertsList'

import { getFeedsForPermission } from '../../common/util/permissions'

const getVisibleAlerts = (alerts, visibilityFilter) => {
  if (!alerts) return []
  let visibleAlerts = alerts.filter(alert =>
    alert.title.toLowerCase().indexOf((visibilityFilter.searchText || '').toLowerCase()) !== -1)
  let now = moment()
  switch (visibilityFilter.filter) {
    case 'ALL':
      return visibleAlerts
    case 'ACTIVE':
      return visibleAlerts.filter(alert =>
        moment(alert.start).isBefore(now) && moment(alert.end).isAfter(now))
    case 'FUTURE':
      return visibleAlerts.filter(alert => moment(alert.start).isAfter(now))
    case 'ARCHIVED':
      return visibleAlerts.filter(alert => moment(alert.end).isBefore(now))
    case 'DRAFT':
      return visibleAlerts.filter(alert => !alert.published)
  }
  return visibleAlerts
}

const mapStateToProps = (state, ownProps) => {
  console.log('all alerts', state.alerts.all)
  // if (state.projects.active !== null && state.projects.active.feeds !== null )
  return {
    isFetching: state.alerts.isFetching,
    alerts: getVisibleAlerts(state.alerts.all, state.alerts.filter),
    visibilityFilter: state.alerts.filter,
    editableFeeds: getFeedsForPermission(state.projects.active, state.user, 'edit-alert'),
    publishableFeeds: getFeedsForPermission(state.projects.active, state.user, 'approve-alert')
  }
}

const mapDispatchToProps = (dispatch, ownProps) => {
  return {
    onEditClick: (alert) => dispatch(editAlert(alert)),
    onDeleteClick: (alert) => dispatch(deleteAlert(alert)),
    searchTextChanged: (text) => dispatch(setVisibilitySearchText(text)),<commit_msg>fixed active alerts to show only published<commit_after>import React from 'react'
import { connect } from 'react-redux'
import moment from 'moment'

import { editAlert, deleteAlert } from '../actions/alerts'
import { setVisibilitySearchText, setVisibilityFilter } from '../actions/visibilityFilter'

import AlertsList from '../components/AlertsList'

import { getFeedsForPermission } from '../../common/util/permissions'

const getVisibleAlerts = (alerts, visibilityFilter) => {
  if (!alerts) return []
  let visibleAlerts = alerts.filter(alert =>
    alert.title.toLowerCase().indexOf((visibilityFilter.searchText || '').toLowerCase()) !== -1)
  let now = moment()
  switch (visibilityFilter.filter) {
    case 'ALL':
      return visibleAlerts
    case 'ACTIVE':
      return visibleAlerts.filter(alert =>
        moment(alert.start).isBefore(now) &&
        moment(alert.end).isAfter(now) &&
        alert.published
      )
    case 'FUTURE':
      return visibleAlerts.filter(alert => moment(alert.start).isAfter(now))
    case 'ARCHIVED':
      return visibleAlerts.filter(alert => moment(alert.end).isBefore(now))
    case 'DRAFT':
      return visibleAlerts.filter(alert => !alert.published)
  }
  return visibleAlerts
}

const mapStateToProps = (state, ownProps) => {
  console.log('all alerts', state.alerts.all)
  // if (state.projects.active !== null && state.projects.active.feeds !== null )
  return {
    isFetching: state.alerts.isFetching,
    alerts: getVisibleAlerts(state.alerts.all, state.alerts.filter),
    visibilityFilter: state.alerts.filter,
    editableFeeds: getFeedsForPermission(state.projects.active, state.user, 'edit-alert'),
    publishableFeeds: getFeedsForPermission(state.projects.active, state.user, 'approve-alert')
  }
}

const mapDispatchToProps = (dispatch, ownProps) => {
  return {
    onEditClick: (alert) => dispatch(editAlert(alert)),
    onDeleteClick: (alert) => dispatch(deleteAlert(alert)),
    searchTextChanged: (text) => dispatch(setVisibilitySearchText(text)),
{'fraction_non_alphanumeric': 0.13809644029285534, 'fraction_numerical': 0.0005049229992426155, 'mean_word_length': 4.419972640218878, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '4149521', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1187, 'n_words': 240}