<commit_before>_ = require 'underscore'
Q = require 'bluebird-q'
Items = require '../../collections/items'

PartnerShows = require '../../collections/partner_shows'
{Cities, FeaturedCities} = require 'places'


@index = (req, res) ->
  shows = new Items [], id: '530ebe92139b21efd6000071', item_type: 'PartnerShow'
  render = ->
    res.render 'index',
      cities: Cities
      featuredCities: FeaturedCities
      featuredShow: shows.models[0]

  shows.fetch success: render, error: render

@city = (req, res, next) ->
  city = _.findWhere(Cities, slug: req.params.city)
  return next() unless city?

  criteria = (status) ->
    near: city.coords.toString()
    displayable: true
    status: status
    sort: '-start_at'
    size: 18

  upcoming = new PartnerShows
  upcoming.comparator = (show) -> Date.parse(show.get('start_at'))
  current = new PartnerShows
  current.comparator = (show) -> Date.parse(show.get('end_at'))
  past = new PartnerShows
  past.comparator = (show) -> -(Date.parse(show.get('end_at')))

  Q.allSettled([
    upcoming.fetch(cache: true, data: criteria('upcoming'))
    current.fetch(cache: true, data: criteria('running'))
    past.fetch(cache: true, data: criteria('closed'))
  ]).then(->
    opening = upcoming.groupBy (show) -> show.openingThisWeek()

    res.locals.sd.CURRENT_CRITERIA = criteria('running')
    res.locals.sd.CURRENT_CRITERIA.comparator = (show) -> Date.parse(show.get('end_at'))

    res.render 'city',
      city: city
      cities: Cities
      featuredCities: FeaturedCities
      opening: opening.true or []
      upcoming: opening.false or []
      current: current.models
      past: past.models
      size: criteria().size
  ).done()

@all_cities = (req, res, next) ->
  res.render 'all_cities', cities: Cities<commit_msg>remove fair booths from shows listings<commit_after>_ = require 'underscore'
Q = require 'bluebird-q'
Items = require '../../collections/items'

PartnerShows = require '../../collections/partner_shows'
{Cities, FeaturedCities} = require 'places'


@index = (req, res) ->
  shows = new Items [], id: '530ebe92139b21efd6000071', item_type: 'PartnerShow'
  render = ->
    res.render 'index',
      cities: Cities
      featuredCities: FeaturedCities
      featuredShow: shows.models[0]

  shows.fetch success: render, error: render

@city = (req, res, next) ->
  city = _.findWhere(Cities, slug: req.params.city)
  return next() unless city?

  criteria = (status) ->
    near: city.coords.toString()
    displayable: true
    status: status
    sort: '-start_at'
    size: 18
    at_a_fair: false

  upcoming = new PartnerShows
  upcoming.comparator = (show) -> Date.parse(show.get('start_at'))
  current = new PartnerShows
  current.comparator = (show) -> Date.parse(show.get('end_at'))
  past = new PartnerShows
  past.comparator = (show) -> -(Date.parse(show.get('end_at')))

  Q.allSettled([
    upcoming.fetch(cache: true, data: criteria('upcoming'))
    current.fetch(cache: true, data: criteria('running'))
    past.fetch(cache: true, data: criteria('closed'))
  ]).then(->
    opening = upcoming.groupBy (show) -> show.openingThisWeek()

    res.locals.sd.CURRENT_CRITERIA = criteria('running')
    res.locals.sd.CURRENT_CRITERIA.comparator = (show) -> Date.parse(show.get('end_at'))

    res.render 'city',
      city: city
      cities: Cities
      featuredCities: FeaturedCities
      opening: opening.true or []
      upcoming: opening.false or []
      current: current.models
      past: past.models
      size: criteria().size
  ).done()

@all_cities = (req, res, next) ->
  res.render 'all_cities', cities: Cities
{'fraction_non_alphanumeric': 0.14867109634551495, 'fraction_numerical': 0.01107419712070875, 'mean_word_length': 3.4826302729528535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '1843827', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1207, 'n_words': 274}