Skip to content

Instantly share code, notes, and snippets.

Created October 10, 2012 18:17
Show Gist options
  • Save anonymous/3867445 to your computer and use it in GitHub Desktop.
Save anonymous/3867445 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Oct 10, 2012.
    25 changes: 25 additions & 0 deletions ReportsController
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    class ReportsController < ApplicationController
    def index
    # get all daily feeds
    @feeds = Feed.where(:feed_type => 'daily')
    @late_daily_feeds = []
    @feeds.each do |d|
    daily_state = FeedStatus.where({:feed_id => d.id, :target_date => Date.today.to_s}).exists? ? "green" : "red"
    daily_time = FeedStatus.where({:feed_id => d.id}).order("updated_at").last
    @late_daily_feeds << {:feed_name => d.feed_name, :state => daily_state, :received => daily_time }
    end
    #@feed_statuses = FeedStatus.includes(:feed).where(:feeds => {:feed_type => 'daily'})
    #@live_feeds = AhProfileError.connection.select_all("select *, (UNIX_TIMESTAMP() - tsecs) as 'seconds ago' from error_log where tsecs > unix_timestamp() - (60*120) and subcomponent like '%ah_%'")
    #@live_feeds = AhProfileError.connection.select_all("select (unix_timestamp() - max(updated_timestamp)) / 60 as 'minutes_ago' from ah_lynx_arrivals")
    @live_feeds = Feed.where(:feed_type =>'pull')
    @late_feeds = []
    @live_feeds.each do |l|
    feed_state = AhProfileError.connection.select_all("select (unix_timestamp() - max(updated_timestamp)) / 60 as 'minutes_ago' from #{l.feed_name}")
    if feed_state[0]["minutes_ago"] > 30
    @late_feeds << {:feed_name => l.feed_name, :minutes_ago => feed_state[0]["minutes_ago"]}
    end
    @intraday_feeds = Feed.where(:feed_type => 'intraday')
    end
    end

    end