Added: branches/invitation_throttling/app/models/activity_limit.rb (0 => 2009)
--- branches/invitation_throttling/app/models/activity_limit.rb (rev 0)
+++ branches/invitation_throttling/app/models/activity_limit.rb 2008-11-27 15:29:27 UTC (rev 2009)
@@ -0,0 +1,2 @@
+class ActivityLimit < ActiveRecord::Base
+end
Added: branches/invitation_throttling/db/migrate/071_create_activity_limits.rb (0 => 2009)
--- branches/invitation_throttling/db/migrate/071_create_activity_limits.rb (rev 0)
+++ branches/invitation_throttling/db/migrate/071_create_activity_limits.rb 2008-11-27 15:29:27 UTC (rev 2009)
@@ -0,0 +1,39 @@
+class CreateActivityLimits < ActiveRecord::Migration
+
+ # This table will hold the state of various limits that can be
+ # imposed on the user / group actions - for example,
+ # limits on the number of internal messages that can be sent over
+ # period of time by some user; or number of invitations that the
+ # user can send
+
+ def self.up
+ create_table :activity_limits do |t|
+ # contributor (e.g. user or group that is limited)
+ t.column :contributor_type, :string, :null => false
+ t.column :contributor_id, :integer, :null => false
+
+ # which action for the contributor is limited
+ t.column :limit_feature, :string, :null => false
+
+ # "limit_max" - maximum number of times (NULL for unlimited) the action can be executed over
+ # "limit_frequency" period (in hours); "limit_frequency" set to NULL means that the limit is not periodic
+ t.column :limit_max, :integer
+ t.column :limit_frequency, :integer
+
+ # number of times the action has already been executed since the last reset (governed by "limit_frequency")
+ t.column :current_count, :integer
+
+ # date/time after which "current_count" is to be reset to "limit_max" (for periodic limits - such as daily message limit)
+ # (NULL to indicate that reset should never happen and the limit is absolute, i.e. non-periodic)
+ t.column :reset_after, :datetime
+
+ # date/time after which promotion to the next level (with, probably, higher "limit_max" should happen)
+ # (NULL to indicate that promotion should never happen and the user is to stay at the same level)
+ t.column :promote_after, :datetime
+ end
+ end
+
+ def self.down
+ drop_table :activity_limits
+ end
+end
Added: branches/invitation_throttling/test/fixtures/activity_limits.yml (0 => 2009)
--- branches/invitation_throttling/test/fixtures/activity_limits.yml (rev 0)
+++ branches/invitation_throttling/test/fixtures/activity_limits.yml 2008-11-27 15:29:27 UTC (rev 2009)
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+two:
+ id: 2
Added: branches/invitation_throttling/test/unit/activity_limit_test.rb (0 => 2009)
--- branches/invitation_throttling/test/unit/activity_limit_test.rb (rev 0)
+++ branches/invitation_throttling/test/unit/activity_limit_test.rb 2008-11-27 15:29:27 UTC (rev 2009)
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class ActivityLimitTest < Test::Unit::TestCase
+ fixtures :activity_limits
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end