<commit_before>import React from 'react'
import { eventHandlers } from './events'
import { SearchFiltersGroup } from '../../components'
import { fieldIndex, domain } from '../../config'

export default function Dataset({ props }) {

  const { store, dispatch } = props
  const { dataset, route } = store

  const atCurrentDataset = route.query.article[0] === dataset.id

  if (dataset.loading || !atCurrentDataset) return <h1>Loading</h1>

  const { closeDataset } = eventHandlers(props)
  const { name, metadata = [] } = dataset.content

  const meta = metadata.reduce((result, { key, value }) => {
    const data = result[key] || []
    result[key] = data.concat([ value ])
    return result
  }, {})

  const description = meta['dc.description.abstract'].map((content, i) => {
    return <p key={i}>{content}</p>
  })

  const fieldMeta = fieldIndex.reduce((result, item) => {

    const { field, key } = item
    if (field in meta && meta[field].length){
      item.tags = meta[field]
      result.push(<li key={field}>
        <header>{item.name}</header>
        <ul className='group'>{ meta[field].map((filter, i) => 
          <li key={i}><a className='tag' href={`#${key}=${filter}`}>{filter}</a></li>
        )}</ul>
      </li>)
    }
    return result

  }, []) 
  
  return <article id='dataset' className='content'>
    <section className='body content'>
      <button className='close button' type='button' onClick={closeDataset}>Close</button>
      <header>
        <h1>{name}</h1>
        {description}
        <ul className='metadata'>{fieldMeta}</ul>
      </header>
    </section>
  </article>

}<commit_msg>Added issued date + metadata<commit_after>import React from 'react'
import { eventHandlers } from './events'
import { SearchFiltersGroup } from '../../components'
import { fieldIndex, domain } from '../../config'

export default function Dataset({ props }) {

  const { store, dispatch } = props
  const { dataset, route } = store

  const atCurrentDataset = route.query.article[0] === dataset.id

  if (dataset.loading || !atCurrentDataset) return <h1>Loading</h1>

  const { closeDataset } = eventHandlers(props)
  const { name, metadata = [] } = dataset.content

  const meta = metadata.reduce((result, { key, value }) => {
    const data = result[key] || []
    result[key] = data.concat([ value ])
    return result
  }, {})

  const description = meta['dc.description.abstract'].map((content, i) => {
    return <p key={i}>{content}</p>
  })

  const fieldMeta = fieldIndex.reduce((result, item) => {

    const { field, key } = item
    if (field in meta && meta[field].length){
      item.tags = meta[field]
      result.push(<li key={field}>
        <header>{item.name}</header>
        <ul className='group'>{ meta[field].map((filter, i) => 
          <li key={i}><a className='tag' href={`#${key}=${filter}`}>{filter}</a></li>
        )}</ul>
      </li>)
    }
    return result

  }, [])

  const issued = meta['dc.date.issued'].reduce((result, date) => {
    const dateObject = new Date(date)
    return {
      date: dateObject,
      day: dateObject.getDate().toString(),
      month: (dateObject.getMonth() + 1).toString(),
      year: dateObject.getFullYear().toString(),
    }
  }, {})
  console.log(meta)

  return <article id='dataset' className='content'>
    <section className='body content'>
      <button className='close button' type='button' onClick={closeDataset}>Close</button>
      <header>
        <h1>{name}</h1>
        {description}
        <h2>Issued</h2>
        <time dateTime={issued.date}>{issued.day}.{issued.month}.{issued.year}</time>
        <h2>Metadata</h2>
        <ul className='metadata'>{fieldMeta}</ul>
      </header>
    </section>
  </article>

}
{'fraction_non_alphanumeric': 0.18230563002680966, 'fraction_numerical': 0.004021447721179625, 'mean_word_length': 3.1455555555555557, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 70, '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': '801592', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1140, 'n_words': 258}