bridge_cache 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/lib/bridge_cache/data/bridge_model.rb +9 -0
- data/app/models/bridge_cache/affiliated_sub_account.rb +3 -2
- data/app/models/bridge_cache/application_record.rb +1 -1
- data/app/models/bridge_cache/bridge_base_model.rb +22 -0
- data/app/models/bridge_cache/course_template.rb +8 -8
- data/app/models/bridge_cache/custom_field.rb +2 -2
- data/app/models/bridge_cache/domain.rb +1 -1
- data/app/models/bridge_cache/enrollment.rb +3 -3
- data/app/models/bridge_cache/grant.rb +3 -3
- data/app/models/bridge_cache/group.rb +6 -6
- data/app/models/bridge_cache/group_enrollment.rb +2 -2
- data/app/models/bridge_cache/learner_custom_field_value.rb +2 -2
- data/app/models/bridge_cache/live_course.rb +6 -6
- data/app/models/bridge_cache/live_course_enrollment.rb +4 -4
- data/app/models/bridge_cache/live_course_session.rb +5 -5
- data/app/models/bridge_cache/live_course_session_registration.rb +5 -5
- data/app/models/bridge_cache/membership.rb +2 -2
- data/app/models/bridge_cache/program.rb +7 -7
- data/app/models/bridge_cache/program_enrollment.rb +3 -3
- data/app/models/bridge_cache/program_group_enrollment.rb +3 -3
- data/app/models/bridge_cache/program_item.rb +2 -2
- data/app/models/bridge_cache/tag.rb +2 -2
- data/app/models/bridge_cache/tagging.rb +3 -3
- data/app/models/bridge_cache/user.rb +13 -13
- data/db/migrate/20170517203244_create_bridge_cache_domains.rb +3 -1
- data/db/migrate/20170517203328_create_bridge_cache_users.rb +1 -0
- data/db/migrate/20170517203421_create_bridge_cache_programs.rb +1 -0
- data/db/migrate/20170517204055_create_bridge_cache_custom_fields.rb +1 -0
- data/db/migrate/20170517204248_create_bridge_cache_grants.rb +1 -0
- data/db/migrate/20170518211404_create_bridge_cache_enrollments.rb +1 -0
- data/db/migrate/20170518211627_create_bridge_cache_groups.rb +1 -0
- data/db/migrate/20170518211703_create_bridge_cache_program_items.rb +1 -0
- data/db/migrate/20170518211714_create_bridge_cache_program_enrollments.rb +1 -0
- data/db/migrate/20170518211736_create_bridge_cache_program_group_enrollments.rb +1 -0
- data/db/migrate/20170518211748_create_bridge_cache_tags.rb +1 -0
- data/db/migrate/20170518211754_create_bridge_cache_taggings.rb +1 -0
- data/db/migrate/20170518211817_create_bridge_cache_course_templates.rb +1 -0
- data/db/migrate/20170523164248_create_bridge_cache_group_enrollments.rb +1 -0
- data/db/migrate/20170523165014_create_bridge_cache_memberships.rb +1 -0
- data/db/migrate/20170615145554_create_bridge_cache_learner_custom_field_values.rb +1 -0
- data/db/migrate/20171017211850_create_affiliated_sub_accounts.rb +1 -0
- data/db/migrate/20171019195443_create_live_courses.rb +1 -0
- data/db/migrate/20171019195503_create_live_course_enrollments.rb +1 -0
- data/db/migrate/20171019195512_create_live_course_session_registrations.rb +1 -0
- data/db/migrate/20171019195516_create_live_course_sessions.rb +1 -0
- data/db/migrate/20171031165231_add_indexes.rb +1 -0
- data/lib/bridge_cache.rb +21 -0
- data/lib/bridge_cache/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcbcf635958dffd3ce2bf3434966ac404855cefd
|
4
|
+
data.tar.gz: d939dd4a949d0c9b48da19d5485337e8389d026a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5955932e3fdc3eb63da5001c8b137d8bb3d6f1ec53a75994bc6f3d3946db4e6bfeca44ccb73d261df7f15ad94130c36f0c1b0579745808650fd1766e8ce08ff3
|
7
|
+
data.tar.gz: d094e6bac904d755590c98df015fd2ae4a16e9bb24f5a03fb0b4dde598183bbd069d729bd3162a2365abca17381a390dc16e268b210d0a7a53e107fd5714e002
|
@@ -1,10 +1,19 @@
|
|
1
1
|
module BridgeCache::Data
|
2
2
|
module BridgeModel
|
3
3
|
|
4
|
+
def adjusted_table_name
|
5
|
+
if BridgeCache.use_internal_database
|
6
|
+
table_name
|
7
|
+
else
|
8
|
+
self.to_s.demodulize.underscore.pluralize
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
def self.extended(base)
|
5
13
|
base.class_eval do
|
6
14
|
scope :in_domain, -> (domain_id) {for_domain(domain_id)}
|
7
15
|
scope :active, -> {is_active?}
|
16
|
+
self.table_name = self.adjusted_table_name
|
8
17
|
end
|
9
18
|
end
|
10
19
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class AffiliatedSubAccount <
|
2
|
+
class AffiliatedSubAccount < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
5
|
before_save :fix_item_type
|
6
6
|
|
7
7
|
belongs_to :item, polymorphic: true, optional: true
|
8
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
8
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -16,5 +16,6 @@ module BridgeCache
|
|
16
16
|
def self.cleanup(current_row_ids)
|
17
17
|
BridgeCache::AffiliatedSubAccount.where.not(bridge_id: current_row_ids).destroy_all
|
18
18
|
end
|
19
|
+
|
19
20
|
end
|
20
21
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module BridgeCache
|
2
|
+
class BridgeBaseModel < ActiveRecord::Base
|
3
|
+
self.abstract_class = true
|
4
|
+
|
5
|
+
def bridge_id
|
6
|
+
if self.class.column_names.include? "bridge_id"
|
7
|
+
self[:bridge_id]
|
8
|
+
else
|
9
|
+
id
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def adjusted_table_name
|
14
|
+
if BridgeCache.use_internal_database
|
15
|
+
table_name
|
16
|
+
else
|
17
|
+
self.to_s.demodulize.underscore.pluralize
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class CourseTemplate <
|
2
|
+
class CourseTemplate < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
6
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
7
|
-
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key:
|
8
|
-
has_many :enrollments, foreign_key: :course_template_id, primary_key:
|
9
|
-
has_many :group_enrollments, foreign_key: :course_template_id, primary_key:
|
10
|
-
has_many :affiliated_sub_accounts, primary_key:
|
5
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
6
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
7
|
+
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
8
|
+
has_many :enrollments, foreign_key: :course_template_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Enrollment'
|
9
|
+
has_many :group_enrollments, foreign_key: :course_template_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::GroupEnrollment'
|
10
|
+
has_many :affiliated_sub_accounts, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::AffiliatedSubAccount', as: :item
|
11
11
|
has_many :domains, through: :affiliated_sub_accounts
|
12
|
-
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key:
|
12
|
+
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
13
13
|
|
14
14
|
def self.for_domain(domain_id)
|
15
15
|
includes(:domains)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class CustomField <
|
2
|
+
class CustomField < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
5
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
6
6
|
has_many :learner_custom_field_values, primary_key: 'bridge_id', foreign_key: :custom_field_id, class_name: 'BridgeCache::LearnerCustomFieldValue'
|
7
7
|
|
8
8
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class Enrollment <
|
2
|
+
class Enrollment < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
5
|
def self.for_domain(domain_id)
|
6
6
|
joins(:course_template).merge(BridgeCache::CourseTemplate.for_domain(domain_id))
|
7
7
|
end
|
8
8
|
|
9
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
10
|
-
belongs_to :course_template, foreign_key: :course_template_id, primary_key:
|
9
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
10
|
+
belongs_to :course_template, foreign_key: :course_template_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::CourseTemplate', optional: true
|
11
11
|
|
12
12
|
end
|
13
13
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class Grant <
|
2
|
+
class Grant < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
6
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
5
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
6
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
7
7
|
|
8
8
|
end
|
9
9
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class Group <
|
2
|
+
class Group < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
5
|
self.inheritance_column = nil
|
6
6
|
|
7
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
8
|
-
has_many :program_group_enrollments, foreign_key: :group_id, primary_key:
|
9
|
-
has_many :group_enrollments, foreign_key: :group_id, primary_key:
|
10
|
-
has_many :memberships, foreign_key: :group_id, primary_key:
|
11
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
7
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
8
|
+
has_many :program_group_enrollments, foreign_key: :group_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::ProgramGroupEnrollment'
|
9
|
+
has_many :group_enrollments, foreign_key: :group_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::GroupEnrollment'
|
10
|
+
has_many :memberships, foreign_key: :group_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Membership'
|
11
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
12
12
|
|
13
13
|
end
|
14
14
|
end
|
@@ -6,8 +6,8 @@ module BridgeCache
|
|
6
6
|
joins(:course_template).where(bridge_cache_course_templates: {domain_id: domain_id})
|
7
7
|
end
|
8
8
|
|
9
|
-
belongs_to :group, foreign_key: :group_id, primary_key:
|
10
|
-
belongs_to :course_template, foreign_key: :course_template_id, primary_key:
|
9
|
+
belongs_to :group, foreign_key: :group_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Group', optional: true
|
10
|
+
belongs_to :course_template, foreign_key: :course_template_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::CourseTemplate', optional: true
|
11
11
|
|
12
12
|
end
|
13
13
|
end
|
@@ -6,8 +6,8 @@ module BridgeCache
|
|
6
6
|
joins(:user).where(bridge_cache_users: {domain_id: domain_id})
|
7
7
|
end
|
8
8
|
|
9
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
10
|
-
belongs_to :custom_field, foreign_key: :custom_field_id, primary_key:
|
9
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
10
|
+
belongs_to :custom_field, foreign_key: :custom_field_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::CustomField', optional: true
|
11
11
|
|
12
12
|
end
|
13
13
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class LiveCourse <
|
2
|
+
class LiveCourse < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
6
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
7
|
-
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key:
|
8
|
-
has_many :live_course_enrollments, foreign_key: :live_course_id, primary_key:
|
9
|
-
has_many :affiliated_sub_accounts, primary_key:
|
5
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
6
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
7
|
+
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
8
|
+
has_many :live_course_enrollments, foreign_key: :live_course_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourseEnrollment'
|
9
|
+
has_many :affiliated_sub_accounts, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::AffiliatedSubAccount', as: :item
|
10
10
|
has_many :domains, through: :affiliated_sub_accounts
|
11
11
|
|
12
12
|
def self.for_domain(domain_id)
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class LiveCourseEnrollment <
|
2
|
+
class LiveCourseEnrollment < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
5
|
def self.for_domain(domain_id)
|
6
6
|
joins(:live_course).merge(BridgeCache::LiveCourse.for_domain(domain_id))
|
7
7
|
end
|
8
8
|
|
9
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
10
|
-
belongs_to :live_course, foreign_key: :live_course_id, primary_key:
|
11
|
-
has_many :live_course_session_registrations, foreign_key: :live_course_enrollment_id, primary_key:
|
9
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
10
|
+
belongs_to :live_course, foreign_key: :live_course_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourse', optional: true
|
11
|
+
has_many :live_course_session_registrations, foreign_key: :live_course_enrollment_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourseSessionRegistration'
|
12
12
|
|
13
13
|
end
|
14
14
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class LiveCourseSession <
|
2
|
+
class LiveCourseSession < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
5
|
def self.for_domain(domain_id)
|
6
6
|
joins(:live_course).merge(BridgeCache::LiveCourse.for_domain(domain_id))
|
7
7
|
end
|
8
8
|
|
9
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
10
|
-
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key:
|
11
|
-
belongs_to :live_course, foreign_key: :live_course_id, primary_key:
|
12
|
-
has_many :live_course_session_registrations, foreign_key: :live_course_session_id, primary_key:
|
9
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
10
|
+
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
11
|
+
belongs_to :live_course, foreign_key: :live_course_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourse', optional: true
|
12
|
+
has_many :live_course_session_registrations, foreign_key: :live_course_session_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourseSessionRegistration'
|
13
13
|
|
14
14
|
end
|
15
15
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class LiveCourseSessionRegistration <
|
2
|
+
class LiveCourseSessionRegistration < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
5
|
def self.for_domain(domain_id)
|
6
6
|
joins(:live_course_enrollment).merge(BridgeCache::LiveCourseEnrollment.for_domain(domain_id))
|
7
7
|
end
|
8
8
|
|
9
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
10
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
11
|
-
belongs_to :live_course_enrollment, primary_key:
|
12
|
-
belongs_to :live_course_session, primary_key:
|
9
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
10
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
11
|
+
belongs_to :live_course_enrollment, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourseEnrollment', optional: true
|
12
|
+
belongs_to :live_course_session, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourseSession', optional: true
|
13
13
|
|
14
14
|
end
|
15
15
|
end
|
@@ -2,8 +2,8 @@ module BridgeCache
|
|
2
2
|
class Membership < ApplicationRecord
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :group, foreign_key: :group_id, primary_key:
|
6
|
-
belongs_to :user, foreign_key: :group_id, primary_key:
|
5
|
+
belongs_to :group, foreign_key: :group_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Group', optional: true
|
6
|
+
belongs_to :user, foreign_key: :group_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
7
7
|
|
8
8
|
def self.for_domain(domain_id)
|
9
9
|
joins(:group).where(bridge_cache_groups: {domain_id: domain_id})
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class Program <
|
2
|
+
class Program < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
6
|
-
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key:
|
7
|
-
has_many :program_items, foreign_key: :program_id, primary_key:
|
8
|
-
has_many :program_enrollments, foreign_key: :program_id, primary_key:
|
9
|
-
has_many :program_group_enrollments, foreign_key: :program_id, primary_key:
|
10
|
-
has_many :affiliated_sub_accounts, primary_key:
|
5
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
6
|
+
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
7
|
+
has_many :program_items, foreign_key: :program_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::ProgramItem'
|
8
|
+
has_many :program_enrollments, foreign_key: :program_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::ProgramEnrollment'
|
9
|
+
has_many :program_group_enrollments, foreign_key: :program_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::ProgramGroupEnrollment'
|
10
|
+
has_many :affiliated_sub_accounts, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::AffiliatedSubAccount', as: :item
|
11
11
|
has_many :domains, through: :affiliated_sub_accounts
|
12
12
|
|
13
13
|
def self.for_domain(domain_id)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class ProgramEnrollment <
|
2
|
+
class ProgramEnrollment < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :user, foreign_key: :user_id, primary_key:
|
6
|
-
belongs_to :program, foreign_key: :program_id, primary_key:
|
5
|
+
belongs_to :user, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
6
|
+
belongs_to :program, foreign_key: :program_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Program', optional: true
|
7
7
|
|
8
8
|
def self.for_domain(domain_id)
|
9
9
|
joins(:program).merge(BridgeCache::Program.for_domain(domain_id))
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class ProgramGroupEnrollment <
|
2
|
+
class ProgramGroupEnrollment < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :group, foreign_key: :group_id, primary_key:
|
6
|
-
belongs_to :program, foreign_key: :program_id, primary_key:
|
5
|
+
belongs_to :group, foreign_key: :group_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Group', optional: true
|
6
|
+
belongs_to :program, foreign_key: :program_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Program', optional: true
|
7
7
|
|
8
8
|
end
|
9
9
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class ProgramItem <
|
2
|
+
class ProgramItem < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :program, foreign_key: :program_id, primary_key:
|
5
|
+
belongs_to :program, foreign_key: :program_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Program', optional: true
|
6
6
|
|
7
7
|
def self.for_domain(domain_id)
|
8
8
|
joins(:program).merge(BridgeCache::Program.for_domain(domain_id))
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class Tag <
|
2
|
+
class Tag < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
has_many :taggings, foreign_key: :tag_id, primary_key:
|
5
|
+
has_many :taggings, foreign_key: :tag_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Tagging'
|
6
6
|
|
7
7
|
end
|
8
8
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class Tagging <
|
2
|
+
class Tagging < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :tag, foreign_key: :tag_id, primary_key:
|
6
|
-
belongs_to :user, foreign_key: :tagger_id, primary_key:
|
5
|
+
belongs_to :tag, foreign_key: :tag_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Tag', optional: true
|
6
|
+
belongs_to :user, foreign_key: :tagger_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::User', optional: true
|
7
7
|
|
8
8
|
def self.cleanup(current_row_ids)
|
9
9
|
BridgeCache::Tagging.where.not(bridge_id: current_row_ids).destroy_all
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module BridgeCache
|
2
|
-
class User <
|
2
|
+
class User < BridgeBaseModel
|
3
3
|
extend BridgeCache::Data::BridgeModel
|
4
4
|
|
5
|
-
belongs_to :domain, foreign_key: :domain_id, primary_key:
|
6
|
-
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key:
|
7
|
-
has_many :enrollments, foreign_key: :user_id, primary_key:
|
8
|
-
has_many :course_templates, foreign_key: :user_id, primary_key:
|
9
|
-
has_many :taggings, foreign_key: :user_id, primary_key:
|
10
|
-
has_many :grants, foreign_key: :user_id, primary_key:
|
11
|
-
has_many :groups, foreign_key: :user_id, primary_key:
|
12
|
-
has_many :program_enrollments, foreign_key: :user_id, primary_key:
|
13
|
-
has_many :memberships, foreign_key: :user_id, primary_key:
|
14
|
-
has_many :learner_custom_field_values, foreign_key: :user_id, primary_key:
|
15
|
-
has_many :live_course_enrollments, foreign_key: :user_id, primary_key:
|
16
|
-
has_many :live_course_session_registrations, foreign_key: :user_id, primary_key:
|
5
|
+
belongs_to :domain, foreign_key: :domain_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
6
|
+
belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Domain', optional: true
|
7
|
+
has_many :enrollments, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Enrollment'
|
8
|
+
has_many :course_templates, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::CourseTemplate'
|
9
|
+
has_many :taggings, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Tagging'
|
10
|
+
has_many :grants, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Grant'
|
11
|
+
has_many :groups, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Group'
|
12
|
+
has_many :program_enrollments, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::ProgramEnrollment'
|
13
|
+
has_many :memberships, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::Membership'
|
14
|
+
has_many :learner_custom_field_values, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LearnerCustomFieldValue'
|
15
|
+
has_many :live_course_enrollments, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourseEnrollment'
|
16
|
+
has_many :live_course_session_registrations, foreign_key: :user_id, primary_key: BridgeCache.primary_key, class_name: 'BridgeCache::LiveCourseSessionRegistration'
|
17
17
|
|
18
18
|
serialize :config
|
19
19
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class CreateBridgeCacheDomains < ActiveRecord::Migration[5.0]
|
2
2
|
def change
|
3
|
-
|
3
|
+
return unless BridgeCache.use_internal_database
|
4
|
+
key = Rails.env == 'test' ? :bridge_cache_domains : :domains
|
5
|
+
create_table key do |t|
|
4
6
|
t.integer :bridge_id, limit: 8
|
5
7
|
t.string :name
|
6
8
|
t.integer :parent_id, limit: 8
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class CreateBridgeCacheLearnerCustomFieldValues < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
|
+
return unless BridgeCache.use_internal_database
|
3
4
|
create_table :bridge_cache_learner_custom_field_values do |t|
|
4
5
|
t.integer :bridge_id, limit: 8
|
5
6
|
t.integer :custom_field_id, limit: 8
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class CreateLiveCourseSessionRegistrations < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
|
+
return unless BridgeCache.use_internal_database
|
3
4
|
create_table :bridge_cache_live_course_session_registrations do |t|
|
4
5
|
t.integer :bridge_id, limit: 8
|
5
6
|
t.integer :live_course_session_id, limit: 8
|
data/lib/bridge_cache.rb
CHANGED
@@ -2,4 +2,25 @@ require "bridge_cache/engine"
|
|
2
2
|
require 'bridge_blueprint'
|
3
3
|
|
4
4
|
module BridgeCache
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
WRITER_METHODS = [:use_internal_database]
|
9
|
+
|
10
|
+
attr_writer(*WRITER_METHODS)
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield self if block_given?
|
14
|
+
end
|
15
|
+
|
16
|
+
def use_internal_database
|
17
|
+
return @use_internal_database if defined?(@use_internal_database)
|
18
|
+
|
19
|
+
@use_internal_database = true
|
20
|
+
end
|
21
|
+
|
22
|
+
def primary_key
|
23
|
+
@use_internal_database ? :bridge_id : :id
|
24
|
+
end
|
25
|
+
end
|
5
26
|
end
|
data/lib/bridge_cache/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bridge_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jshaffer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- app/lib/bridge_cache/webhooks/request.rb
|
206
206
|
- app/models/bridge_cache/affiliated_sub_account.rb
|
207
207
|
- app/models/bridge_cache/application_record.rb
|
208
|
+
- app/models/bridge_cache/bridge_base_model.rb
|
208
209
|
- app/models/bridge_cache/course_template.rb
|
209
210
|
- app/models/bridge_cache/custom_field.rb
|
210
211
|
- app/models/bridge_cache/domain.rb
|