<commit_before>require 'resque/status'

module Resque
  module StatusServer
    
    VIEW_PATH = File.join(File.dirname(__FILE__), 'server', 'views')
    
    def self.registered(app)
      
      app.get '/statuses' do
        @statuses = Resque::Status.statuses
        status_view(:statuses)
      end
      
      app.get '/statuses/:id.js' do
        @status = Resque::Status.get(params[:id])
        content_type :js
        @status.to_json
      end
      
      app.get '/statuses/:id' do
        @status = Resque::Status.get(params[:id])
        status_view(:status)
      end
      
      app.post '/statuses/:id/kill' do
        Resque::Status.kill(params[:id])
        redirect '/statuses'
      end
      
      app.post '/statuses/clear' do
        Resque::Status.clear
        redirect '/statuses'
      end
      
      app.helpers do
        def status_view(filename, options = {}, locals = {})
          erb(File.read(File.join(VIEW_PATH, "#{filename}.erb")), options, locals)
        end
      end
      
      app.tabs << "Statuses"
      
    end

  end
end

Resque::Server.register Resque::StatusServer<commit_msg>use url helper in redirects for relative paths<commit_after>require 'resque/status'

module Resque
  module StatusServer
    
    VIEW_PATH = File.join(File.dirname(__FILE__), 'server', 'views')
    
    def self.registered(app)
      
      app.get '/statuses' do
        @statuses = Resque::Status.statuses
        status_view(:statuses)
      end
      
      app.get '/statuses/:id.js' do
        @status = Resque::Status.get(params[:id])
        content_type :js
        @status.to_json
      end
      
      app.get '/statuses/:id' do
        @status = Resque::Status.get(params[:id])
        status_view(:status)
      end
      
      app.post '/statuses/:id/kill' do
        Resque::Status.kill(params[:id])
        redirect url(:statuses)
      end
      
      app.post '/statuses/clear' do
        Resque::Status.clear
        redirect url(:statuses)
      end
      
      app.helpers do
        def status_view(filename, options = {}, locals = {})
          erb(File.read(File.join(VIEW_PATH, "#{filename}.erb")), options, locals)
        end
      end
      
      app.tabs << "Statuses"
      
    end

  end
end

Resque::Server.register Resque::StatusServer
{'fraction_non_alphanumeric': 0.12115967113803548, 'fraction_numerical': 0.0, 'mean_word_length': 1.964102564102564, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5600860', 'n_tokens_mistral': 723, 'n_tokens_neox': 726, 'n_words': 142}