<commit_before>import { Flex, LargeSelect, Spacer, Toggle } from "@artsy/palette"
import { FilterResetLink } from "Components/FilterResetLink"
import React, { useMemo } from "react"
import { useAuctionResultsFilterContext } from "../../AuctionResultsFilterContext"

const buildDateRange = (startYear: number, endYear: number) =>
  [...Array(1 + endYear - startYear).keys()].map(yearNum => {
    const year = `${yearNum + startYear}`
    return {
      text: year,
      value: year,
    }
  })

export const YearCreated: React.FC = () => {
  const filterContext = useAuctionResultsFilterContext()
  const {
    earliestCreatedYear,
    latestCreatedYear,
    createdAfterYear,
    createdBeforeYear,
  } = filterContext?.filters
  if (
    typeof earliestCreatedYear !== "number" ||
    typeof latestCreatedYear !== "number"
  ) {
    console.error("Couldn't display year created filter due to missing data")
    return null
  }
  const hasChanges =
    earliestCreatedYear !== createdAfterYear ||
    latestCreatedYear !== createdBeforeYear
  const fullDateRange = useMemo(
    () => buildDateRange(earliestCreatedYear, latestCreatedYear),
    [earliestCreatedYear, latestCreatedYear]
  )
  const resetFilter = useMemo(
    () => () => {
      filterContext.setFilter("createdAfterYear", earliestCreatedYear)
      filterContext.setFilter("createdBeforeYear", latestCreatedYear)
    },
    [earliestCreatedYear, latestCreatedYear]
  )

  return (
    <Toggle<commit_msg>Use logger instead of console.error to capture missing data reports<commit_after>import { Flex, LargeSelect, Spacer, Toggle } from "@artsy/palette"
import { FilterResetLink } from "Components/FilterResetLink"
import React, { useMemo } from "react"
import createLogger from "Utils/logger"
import { useAuctionResultsFilterContext } from "../../AuctionResultsFilterContext"

const log = createLogger(
  "Artist/Routes/AuctionResults/Components/AuctionFilters/YearCreated.tsx"
)

const buildDateRange = (startYear: number, endYear: number) =>
  [...Array(1 + endYear - startYear).keys()].map(yearNum => {
    const year = `${yearNum + startYear}`
    return {
      text: year,
      value: year,
    }
  })

export const YearCreated: React.FC = () => {
  const filterContext = useAuctionResultsFilterContext()
  const {
    earliestCreatedYear,
    latestCreatedYear,
    createdAfterYear,
    createdBeforeYear,
  } = filterContext?.filters
  if (
    typeof earliestCreatedYear !== "number" ||
    typeof latestCreatedYear !== "number"
  ) {
    log.error("Couldn't display year created filter due to missing data")
    return null
  }
  const hasChanges =
    earliestCreatedYear !== createdAfterYear ||
    latestCreatedYear !== createdBeforeYear
  const fullDateRange = useMemo(
    () => buildDateRange(earliestCreatedYear, latestCreatedYear),
    [earliestCreatedYear, latestCreatedYear]
  )
  const resetFilter = useMemo(
    () => () => {
      filterContext.setFilter("createdAfterYear", earliestCreatedYear)
      filterContext.setFilter("createdBeforeYear", latestCreatedYear)
    },
    [earliestCreatedYear, latestCreatedYear]
  )

  return (
    <Toggle
{'fraction_non_alphanumeric': 0.11192602040816327, 'fraction_numerical': 0.0006377551020408163, 'mean_word_length': 4.084278768233387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '3439703', 'n_tokens_mistral': 883, 'n_tokens_neox': 889, 'n_words': 202}