bridge_cache 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +15 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/bridge_cache/application.js +13 -0
  6. data/app/assets/stylesheets/bridge_cache/application.css +15 -0
  7. data/app/controllers/bridge_cache/application_controller.rb +5 -0
  8. data/app/helpers/bridge_cache/application_helper.rb +4 -0
  9. data/app/models/bridge_cache/course_template.rb +14 -0
  10. data/app/models/bridge_cache/custom_field.rb +11 -0
  11. data/app/models/bridge_cache/domain.rb +22 -0
  12. data/app/models/bridge_cache/enrollment.rb +12 -0
  13. data/app/models/bridge_cache/grant.rb +12 -0
  14. data/app/models/bridge_cache/group.rb +13 -0
  15. data/app/models/bridge_cache/program.rb +15 -0
  16. data/app/models/bridge_cache/program_enrollment.rb +12 -0
  17. data/app/models/bridge_cache/program_group_enrollment.rb +12 -0
  18. data/app/models/bridge_cache/program_item.rb +11 -0
  19. data/app/models/bridge_cache/tag.rb +11 -0
  20. data/app/models/bridge_cache/tagging.rb +11 -0
  21. data/app/models/bridge_cache/user.rb +20 -0
  22. data/app/views/layouts/bridge_cache/application.html.erb +14 -0
  23. data/config/routes.rb +2 -0
  24. data/db/migrate/20170517203244_create_bridge_cache_domains.rb +18 -0
  25. data/db/migrate/20170517203328_create_bridge_cache_users.rb +30 -0
  26. data/db/migrate/20170517203421_create_bridge_cache_programs.rb +20 -0
  27. data/db/migrate/20170517204055_create_bridge_cache_custom_fields.rb +12 -0
  28. data/db/migrate/20170517204248_create_bridge_cache_grants.rb +13 -0
  29. data/db/migrate/20170518211404_create_bridge_cache_enrollments.rb +24 -0
  30. data/db/migrate/20170518211627_create_bridge_cache_groups.rb +18 -0
  31. data/db/migrate/20170518211703_create_bridge_cache_program_items.rb +12 -0
  32. data/db/migrate/20170518211714_create_bridge_cache_program_enrollments.rb +18 -0
  33. data/db/migrate/20170518211736_create_bridge_cache_program_group_enrollments.rb +12 -0
  34. data/db/migrate/20170518211748_create_bridge_cache_tags.rb +9 -0
  35. data/db/migrate/20170518211754_create_bridge_cache_taggings.rb +14 -0
  36. data/db/migrate/20170518211817_create_bridge_cache_course_templates.rb +37 -0
  37. data/lib/bridge_cache/engine.rb +12 -0
  38. data/lib/bridge_cache/plugins/csv_dump.rb +39 -0
  39. data/lib/bridge_cache/plugins/data_transform.rb +13 -0
  40. data/lib/bridge_cache/version.rb +3 -0
  41. data/lib/bridge_cache.rb +4 -0
  42. data/lib/tasks/bridge_cache_tasks.rake +4 -0
  43. data/test/bridge_cache_test.rb +7 -0
  44. data/test/dummy/README.rdoc +28 -0
  45. data/test/dummy/Rakefile +6 -0
  46. data/test/dummy/app/assets/javascripts/application.js +13 -0
  47. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  48. data/test/dummy/app/controllers/application_controller.rb +5 -0
  49. data/test/dummy/app/helpers/application_helper.rb +2 -0
  50. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  51. data/test/dummy/bin/bundle +3 -0
  52. data/test/dummy/bin/rails +4 -0
  53. data/test/dummy/bin/rake +4 -0
  54. data/test/dummy/bin/setup +29 -0
  55. data/test/dummy/config/application.rb +26 -0
  56. data/test/dummy/config/boot.rb +5 -0
  57. data/test/dummy/config/database.yml +25 -0
  58. data/test/dummy/config/environment.rb +5 -0
  59. data/test/dummy/config/environments/development.rb +41 -0
  60. data/test/dummy/config/environments/production.rb +79 -0
  61. data/test/dummy/config/environments/test.rb +42 -0
  62. data/test/dummy/config/initializers/assets.rb +11 -0
  63. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  64. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  65. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  66. data/test/dummy/config/initializers/inflections.rb +16 -0
  67. data/test/dummy/config/initializers/mime_types.rb +4 -0
  68. data/test/dummy/config/initializers/session_store.rb +3 -0
  69. data/test/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
  70. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  71. data/test/dummy/config/locales/en.yml +23 -0
  72. data/test/dummy/config/routes.rb +4 -0
  73. data/test/dummy/config/secrets.yml +22 -0
  74. data/test/dummy/config.ru +4 -0
  75. data/test/dummy/public/404.html +67 -0
  76. data/test/dummy/public/422.html +67 -0
  77. data/test/dummy/public/500.html +66 -0
  78. data/test/dummy/public/favicon.ico +0 -0
  79. data/test/integration/navigation_test.rb +8 -0
  80. data/test/test_helper.rb +21 -0
  81. metadata +301 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b882dc23a118a27877741ed376e185b9fc5230c
4
+ data.tar.gz: 569a0370556b9ca16a976e8a5a20856c05b4b4eb
5
+ SHA512:
6
+ metadata.gz: a5c32ebaa6d703205ee6f6afcd9dce657b921418218cdba3da310e4578f15e808eae169e720d320f2abd344fcb31a6fefa6021f92467b2b53fefa9502615f35b
7
+ data.tar.gz: 59dc98f5538c1666ef2d7b2f92db9a4b015de3d4a8f9c4ddad02179bf43d97c9c0914fba6b8e9a48cbb17d368eb0d83205b98c6eb49333dfa15de42feecede77
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 jshaffer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,15 @@
1
+ = BridgeCache
2
+
3
+ Bridge Cache is a data dump engine used to cache remote bridge data into a local database.
4
+
5
+ The application mimics the bridge data model and will copy csv rows directly into the local
6
+ data store without any extra configuration
7
+
8
+ == Setup
9
+ gem install 'bridge_cache'
10
+
11
+ rake db:migrate
12
+
13
+
14
+ == Usage
15
+ BridgeCache::User.import_from_csv(path_to_csv)
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'BridgeCache'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ module BridgeCache
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module BridgeCache
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ module BridgeCache
2
+ class CourseTemplate < ActiveRecord::Base
3
+
4
+ belongs_to :user, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::User'
5
+ belongs_to :domain, foreign_key: :domain_id, primary_key: :bridge_id, class_name: 'BridgeCache::Domain'
6
+ belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: :bridge_id, class_name: 'BridgeCache::Domain'
7
+ has_many :enrollments, foreign_key: :course_template_id, primary_key: :bridge_id, class_name: 'BridgeCache::Enrollment'
8
+
9
+ def self.import_from_csv(file_path)
10
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module BridgeCache
2
+ class CustomField < ActiveRecord::Base
3
+
4
+ belongs_to :domain, foreign_key: :domain_id, primary_key: :bridge_id, class_name: 'BridgeCache::Domain'
5
+
6
+ def self.import_from_csv(file_path)
7
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ module BridgeCache
2
+ class Domain < ActiveRecord::Base
3
+
4
+ has_many :domain_children, primary_key: 'bridge_id', foreign_key: 'parent_id', class_name: 'BridgeCache::Domain'
5
+ belongs_to :domain_parent, primary_key: 'bridge_id', foreign_key: 'parent_id', class_name: 'BridgeCache::Domain'
6
+
7
+ has_many :domain_ownees, primary_key: 'bridge_id', foreign_key: 'owner_id', class_name: 'BridgeCache::Domain'
8
+ belongs_to :domain_owner, primary_key: 'bridge_id', foreign_key: 'owner_id', class_name: 'BridgeCache::Domain'
9
+
10
+ has_many :programs, primary_key: 'bridge_id', foreign_key: 'domain_id', class_name: 'BridgeCache::Program'
11
+ has_many :course_templates, primary_key: 'bridge_id', foreign_key: 'domain_id', class_name: 'BridgeCache::CourseTemplate'
12
+ has_many :custom_fields, primary_key: 'bridge_id', foreign_key: 'domain_id', class_name: 'BridgeCache::CustomField'
13
+ has_many :grants, primary_key: 'bridge_id', foreign_key: 'domain_id', class_name: 'BridgeCache::Grant'
14
+
15
+ serialize :config
16
+
17
+ def self.import_from_csv(file_path)
18
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ module BridgeCache
2
+ class Enrollment < ActiveRecord::Base
3
+
4
+ belongs_to :user, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::User'
5
+ belongs_to :course_template, foreign_key: :course_template_id, primary_key: :bridge_id, class_name: 'BridgeCache::CourseTemplate'
6
+
7
+ def self.import_from_csv(file_path)
8
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module BridgeCache
2
+ class Grant < ActiveRecord::Base
3
+
4
+ belongs_to :user, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::User'
5
+ belongs_to :domain, foreign_key: :domain_id, primary_key: :bridge_id, class_name: 'BridgeCache::Domain'
6
+
7
+ def self.import_from_csv(file_path)
8
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module BridgeCache
2
+ class Group < ActiveRecord::Base
3
+ self.inheritance_column = nil
4
+
5
+ belongs_to :user, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::User'
6
+ has_many :program_group_enrollments, foreign_key: :group_id, primary_key: :bridge_id, class_name: 'BridgeCache::ProgramGroupEnrollment'
7
+
8
+ def self.import_from_csv(file_path)
9
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module BridgeCache
2
+ class Program < ActiveRecord::Base
3
+
4
+ belongs_to :domain, foreign_key: :domain_id, primary_key: :bridge_id, class_name: 'BridgeCache::Domain'
5
+ belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: :bridge_id, class_name: 'BridgeCache::Domain'
6
+ has_many :program_items, foreign_key: :program_id, primary_key: :bridge_id, class_name: 'BridgeCache::ProgramItem'
7
+ has_many :program_enrollments, foreign_key: :program_id, primary_key: :bridge_id, class_name: 'BridgeCache::ProgramEnrollment'
8
+ has_many :program_group_enrollments, foreign_key: :program_id, primary_key: :bridge_id, class_name: 'BridgeCache::ProgramGroupEnrollment'
9
+
10
+ def self.import_from_csv(file_path)
11
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module BridgeCache
2
+ class ProgramEnrollment < ActiveRecord::Base
3
+
4
+ belongs_to :user, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::User'
5
+ belongs_to :program, foreign_key: :program_id, primary_key: :bridge_id, class_name: 'BridgeCache::Program'
6
+
7
+ def self.import_from_csv(file_path)
8
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module BridgeCache
2
+ class ProgramGroupEnrollment < ActiveRecord::Base
3
+
4
+ belongs_to :group, foreign_key: :group_id, primary_key: :bridge_id, class_name: 'BridgeCache::Group'
5
+ belongs_to :program, foreign_key: :program_id, primary_key: :bridge_id, class_name: 'BridgeCache::Program'
6
+
7
+ def self.import_from_csv(file_path)
8
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module BridgeCache
2
+ class ProgramItem < ActiveRecord::Base
3
+
4
+ belongs_to :program, foreign_key: :program_id, primary_key: :bridge_id, class_name: 'BridgeCache::Program'
5
+
6
+ def self.import_from_csv(file_path)
7
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module BridgeCache
2
+ class Tag < ActiveRecord::Base
3
+
4
+ has_many :taggings, foreign_key: :tag_id, primary_key: :bridge_id, class_name: 'BridgeCache::Tagging'
5
+
6
+ def self.import_from_csv(file_path)
7
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module BridgeCache
2
+ class Tagging < ActiveRecord::Base
3
+ belongs_to :tag, foreign_key: :tag_id, primary_key: :bridge_id, class_name: 'BridgeCache::Tag'
4
+ belongs_to :user, foreign_key: :tagger_id, primary_key: :bridge_id, class_name: 'BridgeCache::User'
5
+
6
+ def self.import_from_csv(file_path)
7
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ module BridgeCache
2
+ class User < ActiveRecord::Base
3
+
4
+ belongs_to :domain, foreign_key: :domain_id, primary_key: :bridge_id, class_name: 'BridgeCache::Domain'
5
+ belongs_to :sub_account, foreign_key: :sub_account_id, primary_key: :bridge_id, class_name: 'BridgeCache::Domain'
6
+ has_many :enrollments, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::Enrollment'
7
+ has_many :course_templates, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::CourseTemplate'
8
+ has_many :taggings, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::Tagging'
9
+ has_many :grants, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::Grant'
10
+ has_many :groups, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::Group'
11
+ has_many :program_enrollments, foreign_key: :user_id, primary_key: :bridge_id, class_name: 'BridgeCache::ProgramEnrollment'
12
+
13
+ serialize :config
14
+
15
+ def self.import_from_csv(file_path)
16
+ BridgeCache::Plugins::CSVDump::dump_to_table(self, file_path)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>BridgeCache</title>
5
+ <%= stylesheet_link_tag "bridge_cache/application", media: "all" %>
6
+ <%= javascript_include_tag "bridge_cache/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ BridgeCache::Engine.routes.draw do
2
+ end
@@ -0,0 +1,18 @@
1
+ class CreateBridgeCacheDomains < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_domains do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.string :name
6
+ t.integer :parent_id, limit: 8
7
+ t.datetime :created_at
8
+ t.datetime :updated_at
9
+ t.datetime :deleted_at
10
+ t.text :config
11
+ t.integer :owner_id, limit: 8
12
+ t.boolean :active
13
+ t.integer :users_count
14
+ t.integer :course_templates_count
15
+ t.integer :domain_type
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ class CreateBridgeCacheUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_users do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.string :email
6
+ t.string :uid
7
+ t.datetime :created_at
8
+ t.datetime :updated_at
9
+ t.datetime :deleted_at
10
+ t.string :avatar_url
11
+ t.string :first_name
12
+ t.string :last_name
13
+ t.string :external_id
14
+ t.integer :domain_id, limit: 8
15
+ t.datetime :tac_accepted_at
16
+ t.string :tagline
17
+ t.string :locale
18
+ t.boolean :unsubscribed, default: false
19
+ t.datetime :welcomed_at
20
+ t.datetime :logged_in_at
21
+ t.text :config
22
+ t.string :full_name
23
+ t.string :sortable_name
24
+ t.string :uuid
25
+ t.integer :sub_account_id, limit: 8
26
+ t.datetime :hire_date
27
+ t.boolean :hidden, default: false
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ class CreateBridgeCachePrograms < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_programs do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.string :title
6
+ t.datetime :created_at
7
+ t.datetime :updated_at
8
+ t.integer :assignment_period
9
+ t.datetime :published_at
10
+ t.text :unpublished_changes
11
+ t.integer :domain_id, limit: 8
12
+ t.datetime :deleted_at
13
+ t.integer :learner_enrollments_count
14
+ t.integer :sub_account_id, limit: 8
15
+ t.string :description
16
+ t.boolean :has_certificate, default: false
17
+ t.integer :external_id, limit: 8
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ class CreateBridgeCacheCustomFields < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_custom_fields do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.string :name
6
+ t.datetime :created_at
7
+ t.datetime :updated_at
8
+ t.datetime :deleted_at
9
+ t.integer :domain_id, limit: 8
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class CreateBridgeCacheGrants < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_grants do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.integer :user_id, limit: 8
6
+ t.integer :domain_id, limit: 8
7
+ t.datetime :created_at
8
+ t.datetime :updated_at
9
+ t.datetime :deleted_at
10
+ t.string :role_id
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ class CreateBridgeCacheEnrollments < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_enrollments do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.integer :user_id, limit: 8
6
+ t.string :state
7
+ t.datetime :created_at
8
+ t.datetime :updated_at
9
+ t.datetime :completed_at
10
+ t.integer :score
11
+ t.datetime :end_at
12
+ t.integer :course_template_id, limit: 8
13
+ t.integer :attempts_count
14
+ t.boolean :required
15
+ t.string :external_id
16
+ t.datetime :deleted_at
17
+ t.integer :sources_count
18
+ t.text :config
19
+ t.datetime :expires_at
20
+ t.boolean :inactive
21
+ t.datetime :renew_by
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ class CreateBridgeCacheGroups < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_groups do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.string :name
6
+ t.integer :parent_id, limit: 8
7
+ t.datetime :created_at
8
+ t.datetime :updated_at
9
+ t.integer :membership_count
10
+ t.integer :domain_id, limit: 8
11
+ t.datetime :deleted_at
12
+ t.string :type
13
+ t.datetime :archived_at
14
+ t.boolean :new_smart_group
15
+ t.string :external_id
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ class CreateBridgeCacheProgramItems < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_program_items do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.integer :program_id, limit: 8
6
+ t.integer :position
7
+ t.datetime :deleted_at
8
+ t.integer :item_id, limit: 8
9
+ t.string :item_type
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ class CreateBridgeCacheProgramEnrollments < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_program_enrollments do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.integer :user_id, limit: 8
6
+ t.integer :program_id, limit: 8
7
+ t.datetime :created_at
8
+ t.datetime :updated_at
9
+ t.datetime :start_at
10
+ t.integer :state
11
+ t.integer :average_score
12
+ t.datetime :deleted_at
13
+ t.integer :sources_count
14
+ t.text :completed_program_item_ids
15
+ t.integer :program_item_count
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ class CreateBridgeCacheProgramGroupEnrollments < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_program_group_enrollments do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.integer :group_id, limit: 8
6
+ t.integer :program_id, limit: 8
7
+ t.datetime :created_at
8
+ t.datetime :updated_at
9
+ t.datetime :deleted_at
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ class CreateBridgeCacheTags < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_tags do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.string :name
6
+ t.integer :taggings_count
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ class CreateBridgeCacheTaggings < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_taggings do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.integer :tag_id, limit: 8
6
+ t.integer :taggable_id, limit: 8
7
+ t.string :taggable_type
8
+ t.string :tagger_id, limit: 8
9
+ t.string :context
10
+ t.datetime :created_at
11
+ t.text :data
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,37 @@
1
+ class CreateBridgeCacheCourseTemplates < ActiveRecord::Migration
2
+ def change
3
+ create_table :bridge_cache_course_templates do |t|
4
+ t.integer :bridge_id, limit: 8
5
+ t.string :title
6
+ t.integer :estimated_time
7
+ t.integer :user_id, limit: 8
8
+ t.datetime :created_at
9
+ t.datetime :updated_at
10
+ t.integer :passing_threshold
11
+ t.datetime :published_at
12
+ t.integer :default_days_until_due
13
+ t.boolean :has_unpublished_changes
14
+ t.boolean :has_certificate
15
+ t.string :external_id
16
+ t.string :draft_external_id
17
+ t.integer :external_status
18
+ t.integer :course_type
19
+ t.integer :enrollments_count
20
+ t.integer :domain_id, limit: 8
21
+ t.datetime :deleted_at
22
+ t.integer :attachments_count
23
+ t.integer :sub_account_id, limit: 8
24
+ t.boolean :open_book
25
+ t.string :description
26
+ t.integer :third_party_course_id, limit: 8
27
+ t.integer :external_course_id
28
+ t.boolean :force_tinymce
29
+ t.integer :quizzes_count
30
+ t.string :external_status_message
31
+ t.boolean :manual_estimated_time
32
+ t.boolean :force_tinymce_importer_version
33
+ t.boolean :show_correct_response
34
+ t.integer :max_quiz_attempts
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,12 @@
1
+ module BridgeCache
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace BridgeCache
4
+
5
+ config.autoload_once_paths += Dir["#{config.root}/lib/**/"]
6
+
7
+ config.generators do |g|
8
+ g.test_framework :rspec
9
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,39 @@
1
+ require 'csv'
2
+
3
+ module BridgeCache::Plugins
4
+ class CSVDump
5
+
6
+ MAX_ROW_INTERVAL = 5000
7
+
8
+ def self.dump_to_table(clazz, file_path)
9
+ count = 1
10
+ total = 0
11
+ rows = []
12
+ CSV.foreach(file_path, headers: true) do |row|
13
+ total += 1
14
+ end
15
+ CSV.foreach(file_path, headers: true) do |row|
16
+ row = self.remove_bad_columns(clazz, row)
17
+ if count < MAX_ROW_INTERVAL
18
+ rows << clazz.new(BridgeCache::Plugins::DataTransform::set_bridge_id(row).to_h)
19
+ end
20
+ if count % MAX_ROW_INTERVAL == 0 || count == total
21
+ dump_rows(clazz, rows)
22
+ count = 0
23
+ rows = []
24
+ end
25
+ count += 1
26
+ end
27
+ end
28
+
29
+ def self.dump_rows(clazz, rows)
30
+ rows.each {|row| row.save!}
31
+ end
32
+
33
+ def self.remove_bad_columns(clazz, row)
34
+ row = row.delete_if {|key, value| !clazz.column_names.include?(key)}
35
+ row
36
+ end
37
+
38
+ end
39
+ end