Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
593 changed files
with
74,782 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
class AllocationsSweeper < ActionController::Caching::Sweeper | ||
observe Allocation # This sweeper is going to keep an eye on the allocation model | ||
|
||
# If our sweeper detects that an allocation was created call this | ||
def after_save(allocation) | ||
expire_cache_for(allocation) | ||
end | ||
|
||
# If our sweeper detects that an allocation was deleted call this | ||
def after_destroy(allocation) | ||
expire_cache_for(allocation) | ||
end | ||
|
||
def after_votes_create | ||
expire_cache current_user | ||
end | ||
|
||
def after_votes_destroy | ||
expire_cache current_user | ||
end | ||
|
||
def after_account_login | ||
expire_cache current_user | ||
end | ||
|
||
def after_account_continue_openid | ||
expire_cache current_user | ||
end | ||
|
||
private | ||
def expire_cache_for(allocation) | ||
if allocation.class.to_s == 'UserAllocation' | ||
expire_cache(allocation.user) | ||
else | ||
for user in allocation.enterprise.users | ||
expire_cache(user) | ||
end | ||
end | ||
end | ||
|
||
def expire_cache(user) | ||
# Expire a fragment | ||
expire_fragment(:controller => "allocations", :action => "my_allocations", | ||
:user_id => (user == :false ? -1 : user.id)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
class AnnouncementsSweeper < ActionController::Caching::Sweeper | ||
observe Announcement # This sweeper is going to keep an eye on the announcement model | ||
|
||
# If our sweeper detects that an announcement was created call this | ||
def after_save(announcement) | ||
expire_cache_for(announcement) | ||
end | ||
|
||
# If our sweeper detects that an announcement was deleted call this | ||
def after_destroy(announcement) | ||
expire_cache_for(announcement) | ||
end | ||
|
||
def after_announcements_index | ||
expire_fragment(:controller => 'announcements', :action => 'top_five', | ||
:user_id => (logged_in? ? current_user.id : -1)) | ||
end | ||
|
||
private | ||
def expire_cache_for(record) | ||
# Expire a fragment | ||
expire_fragment(%r{announcements/top_five.user_id=*}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
class AttachmentsSweeper < ActionController::Caching::Sweeper | ||
observe Attachment # This sweeper is going to keep an eye on the Attachment model | ||
|
||
# If our sweeper detects that an attachment was created call this | ||
def after_save(attachment) | ||
expire_cache_for(attachment) | ||
end | ||
|
||
# If our sweeper detects that an attachment was deleted call this | ||
def after_destroy(attachment) | ||
expire_cache_for(attachment) | ||
end | ||
|
||
def before_attachments_search | ||
expire_fragment(%r{attachments/list_attachments\.action_type=search&page=(\d)+&user_id=#{current_user.id}}) | ||
end | ||
|
||
private | ||
def expire_cache_for(record) | ||
# Expire a fragment | ||
expire_fragment(%r{attachments/list_attachments.*}) | ||
# expire_fragment(:controller => 'attachments', :action => 'index', | ||
# :page => params[:page] || 1) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
class CommentsSweeper < ActionController::Caching::Sweeper | ||
observe Comment # This sweeper is going to keep an eye on the comment model | ||
|
||
# If our sweeper detects that a comment was created call this | ||
def after_save(comment) | ||
expire_cache_for(comment) | ||
end | ||
|
||
# If our sweeper detects that a comment was deleted call this | ||
def after_destroy(comment) | ||
expire_cache_for(comment) | ||
end | ||
|
||
private | ||
def expire_cache_for(comment) | ||
# Expire a fragment | ||
if comment.class.to_s == 'TopicComment' | ||
expire_fragment(%r{forums/list_forums.user_id=*}) | ||
expire_fragment(%r{forums/most_active.forum=-1&user_id=*}) | ||
expire_fragment(%r{forums/most_active.forum=#{comment.topic.forum.id}&user_id=*}) | ||
# expire_fragment(:controller => 'comments', :action => 'index', | ||
# :page => params[:page] || 1) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
class ForumsSweeper < ActionController::Caching::Sweeper | ||
observe Forum # This sweeper is going to keep an eye on the Forum model | ||
|
||
# If our sweeper detects that a forum was created call this | ||
def after_save(forum) | ||
expire_cache_for(forum) | ||
end | ||
|
||
# If our sweeper detects that a forum was deleted call this | ||
def after_destroy(forum) | ||
expire_cache_for(forum) | ||
end | ||
|
||
def after_forums_mark_all_as_read | ||
expire_fragment(%r{forums/list_forums.user_id=#{current_user.id}}) | ||
end | ||
|
||
def after_watches_create_forum_watch | ||
kill_list_forums_cache | ||
end | ||
|
||
def after_watches_destroy_forum_watch | ||
kill_list_forums_cache | ||
end | ||
|
||
private | ||
def expire_cache_for(record) | ||
# Expire a fragment | ||
kill_list_forums_cache | ||
expire_fragment(%r{forums/most_active.forum=-1&user_id=*}) | ||
# expire_fragment(:controller => 'forums', :action => 'index', | ||
# :page => params[:page] || 1) | ||
end | ||
|
||
def kill_list_forums_cache | ||
expire_fragment(%r{forums/list_forums.user_id=*}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
class LinkSetsSweeper < ActionController::Caching::Sweeper | ||
observe LinkSet # This sweeper is going to keep an eye on the link_set model | ||
|
||
# If our sweeper detects that an link_set was created call this | ||
def after_save(link_set) | ||
expire_cache_for(link_set) | ||
end | ||
|
||
# If our sweeper detects that an link_set was deleted call this | ||
def after_destroy(link_set) | ||
expire_cache_for(link_set) | ||
end | ||
|
||
private | ||
def expire_cache_for(link_set) | ||
# Expire a fragment | ||
expire_fragment(:controller => 'link_sets', :action => 'show_links', | ||
:link_set_id => link_set.id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
class TopicsSweeper < ActionController::Caching::Sweeper | ||
observe Topic # This sweeper is going to keep an eye on the Topic model | ||
|
||
# If our sweeper detects that a topic was created call this | ||
def after_save(topic) | ||
expire_cache_for(topic) | ||
end | ||
|
||
# If our sweeper detects that a topic was deleted call this | ||
def after_destroy(topic) | ||
expire_cache_for(topic) | ||
end | ||
|
||
private | ||
def expire_cache_for(topic) | ||
# Expire a fragment | ||
expire_fragment(%r{forums/list_forums.user_id=*}) | ||
expire_fragment(%r{forums/most_active.forum=-1&user_id=*}) | ||
expire_fragment(%r{forums/most_active.forum=#{topic.forum.id}&user_id=*}) | ||
# expire_fragment(:controller => 'topics', :action => 'index', | ||
# :page => params[:page] || 1) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class CreateTopicImport < ActiveRecord::Migration | ||
def self.up | ||
create_table :topic_imports, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t| | ||
t.string :forum_name, :limit => 50, :null => false | ||
t.string :topic_title, :limit => 200, :null => false | ||
t.string :user_email, :null => false | ||
t.text :comment_body, :null => false | ||
t.timestamps | ||
t.string :status | ||
end | ||
RunIntervalPeriodicJob.create(:job => 'TopicImport.process', | ||
:interval => 600) #once every 10 minutes | ||
end | ||
|
||
def self.down | ||
drop_table :topic_imports | ||
RunIntervalPeriodicJob.find_by_job("TopicImport.process").destroy | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class CreateRates < ActiveRecord::Migration | ||
def self.up | ||
create_table :rates, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t| | ||
t.references :user | ||
t.references :rateable, :polymorphic => true | ||
t.integer :stars | ||
t.string :dimension | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :rates, :user_id | ||
add_index :rates, :rateable_id | ||
end | ||
|
||
def self.down | ||
drop_table :rates | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AddRatingCacheColumn < ActiveRecord::Migration | ||
def self.up | ||
add_column :topics, :rating_average, :decimal, :default => 0 | ||
end | ||
|
||
def self.down | ||
remove_column :topics, :rating_average | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class AddPrivateToComments < ActiveRecord::Migration | ||
def self.up | ||
change_table :comments do |t| | ||
t.boolean :private, :default => false, :null => false | ||
end | ||
end | ||
|
||
def self.down | ||
change_table :comments do |t| | ||
t.remove :private | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
db/migrate/20090118042341_populate_rebuild_index_periodic_job.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class PopulateRebuildIndexPeriodicJob < ActiveRecord::Migration | ||
def self.up | ||
RunAtPeriodicJob.reset_column_information | ||
# Regenerate SOLR indexes | ||
RunAtPeriodicJob.create(:job => 'Topic.rebuild_solr_index; TopicComment.rebuild_solr_index', :run_at_minutes => 210) # run at 3:30AM | ||
end | ||
|
||
def self.down | ||
RunIntervalPeriodicJob.find_by_job("Topic.rebuild_solr_index; TopicComment.rebuild_solr_index").destroy | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
db/migrate/20090118171507_add_last_commented_at_to_topic.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class AddLastCommentedAtToTopic < ActiveRecord::Migration | ||
def self.up | ||
change_table :topics do |t| | ||
t.datetime :last_commented_at | ||
end | ||
|
||
Topic.reset_column_information | ||
for topic in Topic.find(:all) | ||
topic.update_attribute(:last_commented_at, topic.updated_at) | ||
end | ||
end | ||
|
||
def self.down | ||
change_table :topics do |t| | ||
t.remove :last_commented_at | ||
end | ||
end | ||
end |
16 changes: 16 additions & 0 deletions
16
db/migrate/20090118194132_add_power_user_group_to_forum.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class AddPowerUserGroupToForum < ActiveRecord::Migration | ||
extend MigrationHelpers | ||
|
||
def self.up | ||
change_table :forums do |t| | ||
t.column 'power_user_group_id', :integer | ||
end | ||
add_foreign_key(:forums, :power_user_group_id, :groups) | ||
end | ||
|
||
def self.down | ||
change_table :forums do |t| | ||
t.remove :power_user_group_id | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class AddPublishedAtToComments < ActiveRecord::Migration | ||
def self.up | ||
change_table :comments do |t| | ||
t.datetime :published_at | ||
end | ||
|
||
Comment.reset_column_information | ||
for comment in TopicComment.find(:all) | ||
comment.update_attribute(:published_at, comment.created_at) unless comment.private | ||
end | ||
end | ||
|
||
def self.down | ||
change_table :comments do |t| | ||
t.remove :published_at | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class AddPublicToAttachments < ActiveRecord::Migration | ||
def self.up | ||
change_table :attachments do |t| | ||
t.boolean :public, :default => true, :null => false | ||
end | ||
end | ||
|
||
def self.down | ||
change_table :attachments do |t| | ||
t.remove :public | ||
end | ||
end | ||
end |
Oops, something went wrong.