eliminate transaction log items table
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
class SavedSearchesController < ApplicationController
|
class SavedSearchesController < ApplicationController
|
||||||
before_filter :member_only
|
before_filter :member_only
|
||||||
before_fitler :check_availability
|
before_filter :check_availability
|
||||||
respond_to :html, :xml, :json, :js
|
respond_to :html, :xml, :json, :js
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ class UserUpgradesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
unless CurrentUser.user.is_anonymous?
|
|
||||||
TransactionLogItem.record_account_upgrade_view(CurrentUser.user, request.referer)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class UserPromotion
|
|||||||
user.can_upload_free = options[:can_upload_free]
|
user.can_upload_free = options[:can_upload_free]
|
||||||
user.inviter_id = promoter.id
|
user.inviter_id = promoter.id
|
||||||
|
|
||||||
create_transaction_log_item
|
|
||||||
create_user_feedback unless options[:skip_feedback]
|
create_user_feedback unless options[:skip_feedback]
|
||||||
create_dmail unless options[:skip_dmail]
|
create_dmail unless options[:skip_dmail]
|
||||||
update_saved_searches
|
update_saved_searches
|
||||||
@@ -40,10 +39,6 @@ private
|
|||||||
raise User::PrivilegeError if new_level.to_i >= User::Levels::ADMIN
|
raise User::PrivilegeError if new_level.to_i >= User::Levels::ADMIN
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_transaction_log_item
|
|
||||||
TransactionLogItem.record_account_upgrade(user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def build_messages
|
def build_messages
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
class TransactionLogItem < ActiveRecord::Base
|
|
||||||
attr_accessible :category, :data, :user_id
|
|
||||||
validates_inclusion_of :category, :in => %w(
|
|
||||||
account_upgrade_basic_to_gold
|
|
||||||
account_upgrade_basic_to_platinum
|
|
||||||
account_upgrade_gold_to_platinum
|
|
||||||
account_upgrade_view
|
|
||||||
)
|
|
||||||
|
|
||||||
def self.record_account_upgrade_view(user, referrer)
|
|
||||||
create(:category => "account_upgrade_view", :user_id => user.id, :data => referrer)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.record_account_upgrade(user)
|
|
||||||
attributes = {:user_id => user.id}
|
|
||||||
|
|
||||||
if user.level_was < User::Levels::PLATINUM && user.level == User::Levels::PLATINUM
|
|
||||||
attributes[:category] = "account_upgrade_gold_to_platinum"
|
|
||||||
elsif user.level_was < User::Levels::GOLD && user.level == User::Levels::GOLD
|
|
||||||
attributes[:category] = "account_upgrade_basic_to_gold"
|
|
||||||
elsif user.level_was < User::Levels::GOLD && user.level == User::Levels::PLATINUM
|
|
||||||
attributes[:category] = "account_upgrade_basic_to_platinum"
|
|
||||||
end
|
|
||||||
|
|
||||||
create(attributes)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
5
db/migrate/20161221225849_drop_transaction_log_items.rb
Normal file
5
db/migrate/20161221225849_drop_transaction_log_items.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class DropTransactionLogItems < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
drop_table :transaction_log_items
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -3088,39 +3088,6 @@ CREATE SEQUENCE tags_id_seq
|
|||||||
ALTER SEQUENCE tags_id_seq OWNED BY tags.id;
|
ALTER SEQUENCE tags_id_seq OWNED BY tags.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: transaction_log_items; Type: TABLE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE TABLE transaction_log_items (
|
|
||||||
id integer NOT NULL,
|
|
||||||
category character varying,
|
|
||||||
user_id integer,
|
|
||||||
data text,
|
|
||||||
created_at timestamp without time zone,
|
|
||||||
updated_at timestamp without time zone
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: transaction_log_items_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE SEQUENCE transaction_log_items_id_seq
|
|
||||||
START WITH 1
|
|
||||||
INCREMENT BY 1
|
|
||||||
NO MINVALUE
|
|
||||||
NO MAXVALUE
|
|
||||||
CACHE 1;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: transaction_log_items_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER SEQUENCE transaction_log_items_id_seq OWNED BY transaction_log_items.id;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: uploads; Type: TABLE; Schema: public; Owner: -
|
-- Name: uploads; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
@@ -4423,13 +4390,6 @@ ALTER TABLE ONLY tag_subscriptions ALTER COLUMN id SET DEFAULT nextval('tag_subs
|
|||||||
ALTER TABLE ONLY tags ALTER COLUMN id SET DEFAULT nextval('tags_id_seq'::regclass);
|
ALTER TABLE ONLY tags ALTER COLUMN id SET DEFAULT nextval('tags_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER TABLE ONLY transaction_log_items ALTER COLUMN id SET DEFAULT nextval('transaction_log_items_id_seq'::regclass);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
@@ -4847,14 +4807,6 @@ ALTER TABLE ONLY tags
|
|||||||
ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: transaction_log_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER TABLE ONLY transaction_log_items
|
|
||||||
ADD CONSTRAINT transaction_log_items_pkey PRIMARY KEY (id);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
-- Name: uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
@@ -7088,20 +7040,6 @@ CREATE UNIQUE INDEX index_tags_on_name ON tags USING btree (name);
|
|||||||
CREATE INDEX index_tags_on_name_pattern ON tags USING btree (name text_pattern_ops);
|
CREATE INDEX index_tags_on_name_pattern ON tags USING btree (name text_pattern_ops);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_transaction_log_items_on_created_at; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE INDEX index_transaction_log_items_on_created_at ON transaction_log_items USING btree (created_at);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_transaction_log_items_on_user_id; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE INDEX index_transaction_log_items_on_user_id ON transaction_log_items USING btree (user_id);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_uploads_on_uploader_id; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_uploads_on_uploader_id; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
@@ -7522,3 +7460,5 @@ INSERT INTO schema_migrations (version) VALUES ('20161024220345');
|
|||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20161101003139');
|
INSERT INTO schema_migrations (version) VALUES ('20161101003139');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20161221225849');
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class TransactionLogItemTest < ActiveSupport::TestCase
|
|
||||||
setup do
|
|
||||||
@user = FactoryGirl.create(:user)
|
|
||||||
end
|
|
||||||
|
|
||||||
context "Promoting a user" do
|
|
||||||
should "create a new line item in the transaction log" do
|
|
||||||
@user.level = User::Levels::GOLD
|
|
||||||
assert_difference("TransactionLogItem.count", 1) do
|
|
||||||
TransactionLogItem.record_account_upgrade(@user)
|
|
||||||
end
|
|
||||||
|
|
||||||
item = TransactionLogItem.last
|
|
||||||
assert_equal(@user.id, item.user_id)
|
|
||||||
assert_equal("account_upgrade_basic_to_gold", item.category)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "Viewing the account upgrade page" do
|
|
||||||
should "create a new line item in the transaction log" do
|
|
||||||
assert_difference("TransactionLogItem.count", 1) do
|
|
||||||
TransactionLogItem.record_account_upgrade_view(@user, "xxx")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -19,12 +19,6 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.user = FactoryGirl.create(:moderator_user)
|
CurrentUser.user = FactoryGirl.create(:moderator_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a transaction log item" do
|
|
||||||
assert_difference("TransactionLogItem.count") do
|
|
||||||
@user.promote_to!(User::Levels::GOLD)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
should "create a neutral feedback" do
|
should "create a neutral feedback" do
|
||||||
assert_difference("UserFeedback.count") do
|
assert_difference("UserFeedback.count") do
|
||||||
@user.promote_to!(User::Levels::GOLD)
|
@user.promote_to!(User::Levels::GOLD)
|
||||||
|
|||||||
Reference in New Issue
Block a user