Navigation Menu

Skip to content

Commit

Permalink
Added missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
spob committed Mar 14, 2009
1 parent fb45f96 commit 5d584f9
Show file tree
Hide file tree
Showing 593 changed files with 74,782 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -4,4 +4,6 @@ index/**/*
coverage/**/*
config/environments/development.rb
nbproject
db/schema.rb
db/schema.rb
**/.specification
**/cache
49 changes: 49 additions & 0 deletions app/sweepers/allocations_sweeper.rb
@@ -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
27 changes: 27 additions & 0 deletions app/sweepers/announcements_sweeper.rb
@@ -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
28 changes: 28 additions & 0 deletions app/sweepers/attachments_sweeper.rb
@@ -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
28 changes: 28 additions & 0 deletions app/sweepers/comments_sweeper.rb
@@ -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
41 changes: 41 additions & 0 deletions app/sweepers/forums_sweeper.rb
@@ -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
23 changes: 23 additions & 0 deletions app/sweepers/link_sets_sweeper.rb
@@ -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
26 changes: 26 additions & 0 deletions app/sweepers/topics_sweeper.rb
@@ -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
19 changes: 19 additions & 0 deletions db/migrate/20081229014808_create_topic_import.rb
@@ -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
19 changes: 19 additions & 0 deletions db/migrate/20090116033227_create_rates.rb
@@ -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
9 changes: 9 additions & 0 deletions db/migrate/20090116040949_add_rating_cache_column.rb
@@ -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
13 changes: 13 additions & 0 deletions db/migrate/20090118024317_add_private_to_comments.rb
@@ -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 db/migrate/20090118042341_populate_rebuild_index_periodic_job.rb
@@ -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 db/migrate/20090118171507_add_last_commented_at_to_topic.rb
@@ -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 db/migrate/20090118194132_add_power_user_group_to_forum.rb
@@ -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
18 changes: 18 additions & 0 deletions db/migrate/20090119160141_add_published_at_to_comments.rb
@@ -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
13 changes: 13 additions & 0 deletions db/migrate/20090121174906_add_public_to_attachments.rb
@@ -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

0 comments on commit 5d584f9

Please sign in to comment.