<commit_before>import { connect } from 'react-redux'
import { createSelector } from 'reselect'
import LibraryView from './LibraryView'
import { queueSong } from 'routes/Queue/modules/queue'
import { toggleSongStarred } from 'store/modules/user'
import { scrollArtists, toggleArtistExpanded, toggleArtistResultExpanded } from '../modules/library'

const getArtists = (state) => state.artists
const getSongs = (state) => state.songs
const getFilterStr = (state) => state.library.filterStr.trim().toLowerCase()
const getFilterStarred = (state) => state.library.filterStarred
const getStarredArtists = (state) => state.user.starredArtists
const getStarredSongs = (state) => state.user.starredSongs
const getQueue = (state) => state.queue

const getQueuedSongs = createSelector(
  [getQueue],
  (queue) => queue.result.map(queueId => queue.entities[queueId].songId)
)

const getFilterKeywords = createSelector(
  [getFilterStr],
  (str) => str.split(' ')
)

// library filters
// ---------------------

// #1: keyword filters
const getArtistsWithKeyword = createSelector(
  [getArtists, getFilterStr, getFilterKeywords],
  (artists, str, keywords) => {
    if (!str) return artists.result
    return artists.result.filter(id => keywords.some(word => artists.entities[id].name.toLowerCase().includes(word)))
  })

const getSongsWithKeyword = createSelector(
  [getSongs, getFilterStr, getFilterKeywords],
  (songs, str, keywords) => {
    if (!str) return songs.result
    return songs.result.filter(id => keywords.some(word => songs.entities[id].title.toLowerCase().includes(word)))
  })

// #2: starred/hidden filters
const getArtistsByView = createSelector(
  [getArtistsWithKeyword, getFilterStarred, getStarredArtists],
  (artistsWithKeyword, filterStarred, starredArtists) =>
    artistsWithKeyword.filter(artistId => {
      return filterStarred ? starredArtists.includes(artistId) : true
    })
)

const getSongsByView = createSelector(
  [getSongsWithKeyword, getFilterStarred, getStarredSongs],
  (songsWithKeyword, filterStarred, starredSongs) =>
    songsWithKeyword.filter(songId => {
      return filterStarred ? starredSongs.includes(songId) : true
    })
)

const mapStateToProps = (state) => {
  return {<commit_msg>Search should match every keyword, not any<commit_after>import { connect } from 'react-redux'
import { createSelector } from 'reselect'
import LibraryView from './LibraryView'
import { queueSong } from 'routes/Queue/modules/queue'
import { toggleSongStarred } from 'store/modules/user'
import { scrollArtists, toggleArtistExpanded, toggleArtistResultExpanded } from '../modules/library'

const getArtists = (state) => state.artists
const getSongs = (state) => state.songs
const getFilterStr = (state) => state.library.filterStr.trim().toLowerCase()
const getFilterStarred = (state) => state.library.filterStarred
const getStarredArtists = (state) => state.user.starredArtists
const getStarredSongs = (state) => state.user.starredSongs
const getQueue = (state) => state.queue

const getQueuedSongs = createSelector(
  [getQueue],
  (queue) => queue.result.map(queueId => queue.entities[queueId].songId)
)

const getFilterKeywords = createSelector(
  [getFilterStr],
  (str) => str.split(' ')
)

// library filters
// ---------------------

// #1: keyword filters
const getArtistsWithKeyword = createSelector(
  [getArtists, getFilterStr, getFilterKeywords],
  (artists, str, keywords) => {
    if (!str) return artists.result
    return artists.result.filter(id => keywords.every(word => artists.entities[id].name.toLowerCase().includes(word)))
  })

const getSongsWithKeyword = createSelector(
  [getSongs, getFilterStr, getFilterKeywords],
  (songs, str, keywords) => {
    if (!str) return songs.result
    return songs.result.filter(id => keywords.every(word => songs.entities[id].title.toLowerCase().includes(word)))
  })

// #2: starred/hidden filters
const getArtistsByView = createSelector(
  [getArtistsWithKeyword, getFilterStarred, getStarredArtists],
  (artistsWithKeyword, filterStarred, starredArtists) =>
    artistsWithKeyword.filter(artistId => {
      return filterStarred ? starredArtists.includes(artistId) : true
    })
)

const getSongsByView = createSelector(
  [getSongsWithKeyword, getFilterStarred, getStarredSongs],
  (songsWithKeyword, filterStarred, starredSongs) =>
    songsWithKeyword.filter(songId => {
      return filterStarred ? starredSongs.includes(songId) : true
    })
)

const mapStateToProps = (state) => {
  return {
{'fraction_non_alphanumeric': 0.13444816053511705, 'fraction_numerical': 0.0008918617614269788, 'mean_word_length': 4.973368841544607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 45, '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': '818928', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1369, 'n_words': 288}