Right before this line:
if Date.today - connection.logs.order("timestamp DESC").first.timestamp > 0