<commit_before>const React = require('react')
const { connect } = require('react-redux')
const AlbumTable = require('./AlbumTable.jsx')
const MobilePageHeader = require('../MobilePageHeader.jsx')
const InitialImportMessage = require('../InitialImportMessage.jsx')

function AlbumOverview ({ albums }) {
  var albumsDisplay = albums.length > 0 ? <AlbumTable albums={albums}/>
      : <InitialImportMessage/>

  return (
      <div>
        <MobilePageHeader title='Albums'/>
        <div className='page-heading'>
          <h2>Albums</h2>
        </div>
        <div className='actual-page-content'>
          {albumsDisplay}
        </div>
      </div>
  )
}

function mapStateToProps (state) {
  // Grab the albums from the songs
  var albums = _uniqueArray(state.songs.map((song) => ({
    album: song.album,
    coverUrl: _getCover(song.coverId, state)
  })))

  // Remove empty albums
  albums = albums.filter(a => a.album)

  // Add the song number to the albums
  albums = albums.map(x => {
    x.songs = state.songs.filter(y => y.album === x.album).length
    return x
  })

  // Order the albums by the album title
  albums.sort((a, b) => (a.album > b.album) ? 1 : ((b.album > a.album) ? -1 : 0))

  return {albums}
}

function _uniqueArray (array) {
  array = array.map(x => JSON.stringify(x))
  array = array.filter((v, i, self) => self.indexOf(v) === i)
  return array.map(x => JSON.parse(x))<commit_msg>Fix missbehaving filtering with cover set<commit_after>const React = require('react')
const { connect } = require('react-redux')
const AlbumTable = require('./AlbumTable.jsx')
const MobilePageHeader = require('../MobilePageHeader.jsx')
const InitialImportMessage = require('../InitialImportMessage.jsx')

function AlbumOverview ({ albums }) {
  var albumsDisplay = albums.length > 0 ? <AlbumTable albums={albums}/>
      : <InitialImportMessage/>

  return (
      <div>
        <MobilePageHeader title='Albums'/>
        <div className='page-heading'>
          <h2>Albums</h2>
        </div>
        <div className='actual-page-content'>
          {albumsDisplay}
        </div>
      </div>
  )
}

function mapStateToProps (state) {
  // Grab the albums from the songs
  var albums = _uniqueArray(state.songs.map((song) => ({
    album: song.album
  })))

  // Remove empty albums
  albums = albums.filter(a => a.album)

  // Add the song number to the albums
  albums = albums.map(x => {
    x.songs = state.songs.filter(y => y.album === x.album).length
    x.coverUrl = _getCover(state.songs.find(y => y.album === x.album).coverId, state)
    return x
  })

  // Order the albums by the album title
  albums.sort((a, b) => (a.album > b.album) ? 1 : ((b.album > a.album) ? -1 : 0))

  return {albums}
}

function _uniqueArray (array) {
  array = array.map(x => JSON.stringify(x))
  array = array.filter((v, i, self) => self.indexOf(v) === i)
  return array.map(x => JSON.parse(x))
{'fraction_non_alphanumeric': 0.1610344827586207, 'fraction_numerical': 0.004137931034482759, 'mean_word_length': 3.0516759776536313, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 48, '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': '6330685', 'n_tokens_mistral': 967, 'n_tokens_neox': 941, 'n_words': 224}