Skip to content
Snippets Groups Projects
Commit 0dfcbca5 authored by danielgrippi's avatar danielgrippi
Browse files

Revert "removed the pod_stats table (was the cause of bloat on the database)."

This reverts commit 902c40e4.
parent 902c40e4
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,10 @@ module Job
end
end
unless response.success?
pod = Pod.find_or_create_by_url(response.effective_url)
log_line = "event=http_multi_fail sender_id=#{user_id} recipient_id=#{person.id} url=#{response.effective_url} response_code='#{response.code}'"
Rails.logger.info(log_line)
pod.pod_stats.create(:error_message => log_line, :person_id => person.id, :error_code => response.code.to_i)
failed_request_people << person.id
end
end
......
class Pod < ActiveRecord::Base
has_many :pod_stats
def self.find_or_create_by_url(url)
u = URI.parse(url)
pod = self.find_or_initialize_by_host(u.host)
unless pod.persisted?
pod.ssl = (u.scheme == 'https')? true : false
pod.save
end
pod
end
end
class PodStat < ActiveRecord::Base
belongs_to :pod
end
class RemovePodStatsTable < ActiveRecord::Migration
def self.up
drop_table :pods
drop_table :pod_stats
end
def self.down
create_table :pods do |t|
t.string :host
t.boolean :ssl
t.timestamps
end
create_table :pod_stats do |t|
t.integer :error_code
t.integer :person_id
t.text :error_message
t.integer :pod_id
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110830000140) do
ActiveRecord::Schema.define(:version => 20110818212541) do
create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false
......@@ -236,6 +236,22 @@ ActiveRecord::Schema.define(:version => 20110830000140) do
add_index "people", ["guid"], :name => "index_people_on_guid", :unique => true
add_index "people", ["owner_id"], :name => "index_people_on_owner_id", :unique => true
create_table "pod_stats", :force => true do |t|
t.integer "error_code"
t.integer "person_id"
t.text "error_message"
t.integer "pod_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "pods", :force => true do |t|
t.string "host"
t.boolean "ssl"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "post_visibilities", :force => true do |t|
t.integer "post_id", :null => false
t.datetime "created_at"
......
require 'spec_helper'
describe Pod do
it 'has many pod_stats' do
Pod.new.pod_stats.should be_empty
end
describe '.find_or_create_by_url' do
it 'takes a url, and makes one by host' do
pod = Pod.find_or_create_by_url('https://joindiaspora.com/maxwell')
pod.host.should == 'joindiaspora.com'
end
it 'sets ssl boolean(side-effect)' do
pod = Pod.find_or_create_by_url('https://joindiaspora.com/maxwell')
pod.ssl.should be_true
end
end
end
require 'spec_helper'
describe PodStat do
pending "add some examples to (or delete) #{__FILE__}"
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment