<commit_before>import { Box, Separator, Serif, Theme } from "@artsy/palette"
import { FairDetail_fair } from "__generated__/FairDetail_fair.graphql"
import { CaretButton } from "lib/Components/Buttons/CaretButton"
import SwitchBoard from "lib/NativeModules/SwitchBoard"
import React from "react"
import { FlatList, ViewProperties } from "react-native"
import { createPaginationContainer, graphql, RelayPaginationProp } from "react-relay"

import { HoursCollapsible } from "lib/Components/HoursCollapsible"
import { LocationMapContainer as LocationMap, PartnerType } from "lib/Components/LocationMap"
import { PAGE_SIZE } from "lib/data/constants"
import { Schema, screenTrack, Track, track as _track } from "lib/utils/track"
import { ArtistsExhibitorsWorksLink } from "../Components/ArtistsExhibitorsWorksLink"
import { FairBoothPreviewContainer as FairBoothPreview } from "../Components/FairBoothPreview"
import { FairHeaderContainer as FairHeader } from "../Components/FairHeader"
import { SearchLink } from "../Components/SearchLink"
import { shouldShowFairBMWArtActivationLink } from "./FairBMWArtActivation"
import { shouldGoStraightToWebsite, shouldShowFairMoreInfo } from "./FairMoreInfo"

interface Props extends ViewProperties {
  fair: FairDetail_fair
  relay: RelayPaginationProp
}

interface State {
  sections: Array<{
    type: "hours" | "location"
    data: any
  }>
  boothCount: number
  extraData?: { animatedValue: { height: number } }
}
const track: Track<Props, State> = _track

@screenTrack<Props>(props => ({
  context_screen: Schema.PageNames.FairPage,
  context_screen_owner_type: Schema.OwnerEntityTypes.Fair,
  context_screen_owner_slug: props.fair.id,
  context_screen_owner_id: props.fair._id,
}))
export class FairDetail extends React.Component<Props, State> {
  state: State = {
    sections: [],
    boothCount: 0,
  }

  componentWillReceiveProps(nextProps) {
    if (this.props.fair.shows.edges.length !== nextProps.fair.shows.edges.length) {
      this.updateSections()
    }
  }

  componentDidMount() {
    this.updateSections()
  }

  updateSections = () => {
    const { fair } = this.props
    const {
      counts: { artists, artworks, partners },
    } = fair
    const sections = []

    const coords = fair.location.coordinates
    if (coords && coords.lat && coords.lng) {
      sections.push({
        type: "location",
        data: {
          location: fair.location,
          partnerName: fair.profile ? fair.profile.name : fair.name,
          partnerType: PartnerType.fair,
        },
      })
    }

    if (shouldGoStraightToWebsite(this.props.fair) || shouldShowFairMoreInfo(this.props.fair)) {
      sections.push({
        type: "information",
      })
    }

    if (shouldShowFairBMWArtActivationLink(this.props.fair)) {
      sections.push({
        type: "bmw-art-activation",
      })
    }

    if (fair.hours) {
      sections.push({
        type: "hours",
        data: {
          hours: fair.hours,
        },
      })
    }

    if (!!artists || !!artworks || !!partners) {<commit_msg>Fix fair [Objct object] for hours issue<commit_after>import { Box, Separator, Serif, Theme } from "@artsy/palette"
import { FairDetail_fair } from "__generated__/FairDetail_fair.graphql"
import { CaretButton } from "lib/Components/Buttons/CaretButton"
import SwitchBoard from "lib/NativeModules/SwitchBoard"
import React from "react"
import { FlatList, ViewProperties } from "react-native"
import { createPaginationContainer, graphql, RelayPaginationProp } from "react-relay"

import { HoursCollapsible } from "lib/Components/HoursCollapsible"
import { LocationMapContainer as LocationMap, PartnerType } from "lib/Components/LocationMap"
import { PAGE_SIZE } from "lib/data/constants"
import { Schema, screenTrack, Track, track as _track } from "lib/utils/track"
import { ArtistsExhibitorsWorksLink } from "../Components/ArtistsExhibitorsWorksLink"
import { FairBoothPreviewContainer as FairBoothPreview } from "../Components/FairBoothPreview"
import { FairHeaderContainer as FairHeader } from "../Components/FairHeader"
import { SearchLink } from "../Components/SearchLink"
import { shouldShowFairBMWArtActivationLink } from "./FairBMWArtActivation"
import { shouldGoStraightToWebsite, shouldShowFairMoreInfo } from "./FairMoreInfo"

interface Props extends ViewProperties {
  fair: FairDetail_fair
  relay: RelayPaginationProp
}

interface State {
  sections: Array<{
    type: "hours" | "location"
    data: any
  }>
  boothCount: number
  extraData?: { animatedValue: { height: number } }
}
const track: Track<Props, State> = _track

@screenTrack<Props>(props => ({
  context_screen: Schema.PageNames.FairPage,
  context_screen_owner_type: Schema.OwnerEntityTypes.Fair,
  context_screen_owner_slug: props.fair.id,
  context_screen_owner_id: props.fair._id,
}))
export class FairDetail extends React.Component<Props, State> {
  state: State = {
    sections: [],
    boothCount: 0,
  }

  componentWillReceiveProps(nextProps) {
    if (this.props.fair.shows.edges.length !== nextProps.fair.shows.edges.length) {
      this.updateSections()
    }
  }

  componentDidMount() {
    this.updateSections()
  }

  updateSections = () => {
    const { fair } = this.props
    const {
      counts: { artists, artworks, partners },
    } = fair
    const sections = []

    const coords = fair.location.coordinates
    if (coords && coords.lat && coords.lng) {
      sections.push({
        type: "location",
        data: {
          location: fair.location,
          partnerName: fair.profile ? fair.profile.name : fair.name,
          partnerType: PartnerType.fair,
        },
      })
    }

    if (shouldGoStraightToWebsite(this.props.fair) || shouldShowFairMoreInfo(this.props.fair)) {
      sections.push({
        type: "information",
      })
    }

    if (shouldShowFairBMWArtActivationLink(this.props.fair)) {
      sections.push({
        type: "bmw-art-activation",
      })
    }
    if (fair.hours) {
      sections.push({
        type: "hours",
        data: fair.hours,
      })
    }

    if (!!artists || !!artworks || !!partners) {
{'fraction_non_alphanumeric': 0.11731935113878421, 'fraction_numerical': 0.00032770768474520726, 'mean_word_length': 3.6277482941622443, 'pattern_counts': {'":': 0, '<': 11, '<?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': '662859', 'n_tokens_mistral': 1911, 'n_tokens_neox': 1845, 'n_words': 397}