<commit_before>class BulletinsController < ApplicationController
  expose(:longitude) do
    params[:longitude].try(:to_f) || request.location.longitude
  end

  expose(:latitude) do
    params[:latitude].try(:to_f) || request.location.latitude
  end

  expose(:date) do
    latlon = [latitude, longitude]
    Time.zone = Timezone::Zone.new(latlon: latlon).zone
    Chronic.time_class = Time.zone
    Chronic.parse(params[:date]).try(:to_date) || Time.zone.today
  end

  expose(:bulletin) do
    Bulletin.new(date, longitude: longitude, latitude: latitude)
  end

  def show
    str = date.in_time_zone.to_s
    key = [str, longitude, latitude].join(':')
    if Redis.current.exists(key)
      respond_with(bulletin)
    else
      BulletinWorker.perform_async(str, longitude, latitude)
      render(template: 'bulletins/busy', status: :accepted)
    end
  end
end
<commit_msg>Fix bug in bulletins/busy for json<commit_after>class BulletinsController < ApplicationController
  expose(:longitude) do
    params[:longitude].try(:to_f) || request.location.longitude
  end

  expose(:latitude) do
    params[:latitude].try(:to_f) || request.location.latitude
  end

  expose(:date) do
    latlon = [latitude, longitude]
    Time.zone = Timezone::Zone.new(latlon: latlon).zone
    Chronic.time_class = Time.zone
    Chronic.parse(params[:date]).try(:to_date) || Time.zone.today
  end

  expose(:bulletin) do
    Bulletin.new(date, longitude: longitude, latitude: latitude)
  end

  def show
    str = date.in_time_zone.to_s
    key = [str, longitude, latitude].join(':')
    if Redis.current.exists(key)
      respond_with(bulletin)
    else
      BulletinWorker.perform_async(str, longitude, latitude)
      respond_to do |format|
        format.json { render(json: {}, status: :accepted) }
        format.html { render(template: 'bulletins/busy', status: :accepted) }
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.12407602956705385, 'fraction_numerical': 0.0, 'mean_word_length': 3.7256857855361596, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4877822', 'n_tokens_mistral': 645, 'n_tokens_neox': 622, 'n_words': 126}