supplejack_api 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.
- checksums.yaml +7 -0
- data/README.md +80 -0
- data/Rakefile +42 -0
- data/app/assets/javascripts/supplejack_api/application.js +26 -0
- data/app/assets/stylesheets/supplejack_api/application.css +30 -0
- data/app/controllers/supplejack_api/admin/base_controller.rb +24 -0
- data/app/controllers/supplejack_api/admin/sessions_controller.rb +25 -0
- data/app/controllers/supplejack_api/admin/site_activities_controller.rb +21 -0
- data/app/controllers/supplejack_api/admin/users_controller.rb +55 -0
- data/app/controllers/supplejack_api/application_controller.rb +70 -0
- data/app/controllers/supplejack_api/concepts_controller.rb +52 -0
- data/app/controllers/supplejack_api/concerns/ignore_metrics.rb +14 -0
- data/app/controllers/supplejack_api/concerns/records_controller_metrics.rb +26 -0
- data/app/controllers/supplejack_api/concerns/set_items_controller_metrics.rb +20 -0
- data/app/controllers/supplejack_api/concerns/user_sets_controller_metrics.rb +26 -0
- data/app/controllers/supplejack_api/harvester/concepts_controller.rb +41 -0
- data/app/controllers/supplejack_api/harvester/fragments_controller.rb +30 -0
- data/app/controllers/supplejack_api/harvester/records_controller.rb +68 -0
- data/app/controllers/supplejack_api/metrics_api_controller.rb +44 -0
- data/app/controllers/supplejack_api/partners_controller.rb +39 -0
- data/app/controllers/supplejack_api/records_controller.rb +71 -0
- data/app/controllers/supplejack_api/schema_controller.rb +19 -0
- data/app/controllers/supplejack_api/set_items_controller.rb +38 -0
- data/app/controllers/supplejack_api/sources_controller.rb +67 -0
- data/app/controllers/supplejack_api/status_controller.rb +67 -0
- data/app/controllers/supplejack_api/user_sets_controller.rb +97 -0
- data/app/controllers/supplejack_api/users_controller.rb +49 -0
- data/app/helpers/supplejack_api/application_helper.rb +39 -0
- data/app/helpers/supplejack_api/facets_helper.rb +30 -0
- data/app/mailers/supplejack_api/request_limit_mailer.rb +43 -0
- data/app/models/supplejack_api/api_concept/concept_fragment.rb +31 -0
- data/app/models/supplejack_api/api_record/record_fragment.rb +15 -0
- data/app/models/supplejack_api/concept.rb +46 -0
- data/app/models/supplejack_api/concept_search.rb +86 -0
- data/app/models/supplejack_api/concerns/queryable_by_date.rb +31 -0
- data/app/models/supplejack_api/concerns/record.rb +108 -0
- data/app/models/supplejack_api/concerns/record_fragmentable.rb +24 -0
- data/app/models/supplejack_api/concerns/searchable.rb +430 -0
- data/app/models/supplejack_api/concerns/user_set.rb +219 -0
- data/app/models/supplejack_api/daily_metrics.rb +20 -0
- data/app/models/supplejack_api/faceted_metrics.rb +55 -0
- data/app/models/supplejack_api/fragment.rb +82 -0
- data/app/models/supplejack_api/interaction_models/record.rb +60 -0
- data/app/models/supplejack_api/interaction_models/set.rb +13 -0
- data/app/models/supplejack_api/interaction_updaters/all_usage_metric.rb +41 -0
- data/app/models/supplejack_api/interaction_updaters/set_metrics.rb +32 -0
- data/app/models/supplejack_api/interaction_updaters/usage_metrics.rb +73 -0
- data/app/models/supplejack_api/partner.rb +24 -0
- data/app/models/supplejack_api/preview_record.rb +30 -0
- data/app/models/supplejack_api/record.rb +18 -0
- data/app/models/supplejack_api/record_search.rb +12 -0
- data/app/models/supplejack_api/schema_definition.rb +147 -0
- data/app/models/supplejack_api/search.rb +14 -0
- data/app/models/supplejack_api/set_item.rb +57 -0
- data/app/models/supplejack_api/site_activity.rb +59 -0
- data/app/models/supplejack_api/source.rb +28 -0
- data/app/models/supplejack_api/source_activity.rb +36 -0
- data/app/models/supplejack_api/source_authority.rb +42 -0
- data/app/models/supplejack_api/supplejack_schema.rb +37 -0
- data/app/models/supplejack_api/support/concept/searchable.rb +79 -0
- data/app/models/supplejack_api/support/concept/storable.rb +59 -0
- data/app/models/supplejack_api/support/fragment_helpers.rb +96 -0
- data/app/models/supplejack_api/support/harvestable.rb +105 -0
- data/app/models/supplejack_api/support/searchable.rb +115 -0
- data/app/models/supplejack_api/support/status_logger.rb +23 -0
- data/app/models/supplejack_api/support/storable.rb +49 -0
- data/app/models/supplejack_api/support/validation_logger.rb +23 -0
- data/app/models/supplejack_api/usage_metrics.rb +25 -0
- data/app/models/supplejack_api/user.rb +211 -0
- data/app/models/supplejack_api/user_activity.rb +65 -0
- data/app/models/supplejack_api/user_set.rb +17 -0
- data/app/serializers/supplejack_api/application_serializer.rb +12 -0
- data/app/serializers/supplejack_api/concept_record_serializer.rb +23 -0
- data/app/serializers/supplejack_api/concept_search_serializer.rb +12 -0
- data/app/serializers/supplejack_api/concept_serializer.rb +100 -0
- data/app/serializers/supplejack_api/concerns/record_serializable.rb +119 -0
- data/app/serializers/supplejack_api/concerns/search_serializable.rb +24 -0
- data/app/serializers/supplejack_api/record_search_serializer.rb +64 -0
- data/app/serializers/supplejack_api/record_serializer.rb +13 -0
- data/app/serializers/supplejack_api/search_serializer.rb +13 -0
- data/app/serializers/supplejack_api/source_authority_serializer.rb +23 -0
- data/app/serializers/supplejack_api/user_serializer.rb +13 -0
- data/app/serializers/supplejack_api/user_set_record_serializer.rb +14 -0
- data/app/serializers/supplejack_api/user_set_serializer.rb +77 -0
- data/app/services/metrics_api/v3/api.rb +30 -0
- data/app/services/metrics_api/v3/endpoints/facets.rb +23 -0
- data/app/services/metrics_api/v3/endpoints/global.rb +26 -0
- data/app/services/metrics_api/v3/endpoints/helpers.rb +14 -0
- data/app/services/metrics_api/v3/endpoints/root.rb +97 -0
- data/app/services/metrics_api/v3/presenters/daily_metric.rb +23 -0
- data/app/services/metrics_api/v3/presenters/extended_metadata.rb +41 -0
- data/app/services/metrics_api/v3/presenters/record.rb +26 -0
- data/app/services/metrics_api/v3/presenters/view.rb +28 -0
- data/app/views/layouts/supplejack_api/_head.html.erb +17 -0
- data/app/views/layouts/supplejack_api/_top_nav.html.erb +33 -0
- data/app/views/layouts/supplejack_api/application.html.erb +33 -0
- data/app/views/supplejack_api/admin/sessions/new.html.erb +25 -0
- data/app/views/supplejack_api/admin/shared/_links.erb +34 -0
- data/app/views/supplejack_api/admin/site_activities/index.csv.erb +22 -0
- data/app/views/supplejack_api/admin/site_activities/index.html.erb +54 -0
- data/app/views/supplejack_api/admin/users/edit.html.erb +16 -0
- data/app/views/supplejack_api/admin/users/index.csv.erb +22 -0
- data/app/views/supplejack_api/admin/users/index.html.erb +57 -0
- data/app/views/supplejack_api/admin/users/show.html.erb +33 -0
- data/app/views/supplejack_api/request_limit_mailer/at100percent.text.erb +13 -0
- data/app/views/supplejack_api/request_limit_mailer/at100percent_admin.text.erb +1 -0
- data/app/views/supplejack_api/request_limit_mailer/at90percent.text.erb +13 -0
- data/app/views/supplejack_api/request_limit_mailer/at90percent_admin.text.erb +1 -0
- data/app/workers/supplejack_api/daily_metrics_worker.rb +112 -0
- data/app/workers/supplejack_api/interaction_metrics_worker.rb +45 -0
- data/config/cucumber.yml +16 -0
- data/config/initializers/force_eagerload.rb +11 -0
- data/config/initializers/interaction_updaters.rb +7 -0
- data/config/routes.rb +81 -0
- data/db/binding_records.development.json +7 -0
- data/db/binding_records.staging.json +7 -0
- data/db/concepts.json +33 -0
- data/db/concepts_data.json +569745 -0
- data/db/source_authorities.json +119 -0
- data/lib/generators/supplejack_api/install_generator.rb +124 -0
- data/lib/mongoid/paperclip.rb +53 -0
- data/lib/mongoid/string.rb +20 -0
- data/lib/sunspot/mongoid.rb +51 -0
- data/lib/sunspot/resque_session_proxy.rb +72 -0
- data/lib/sunspot/sunspot_spellcheck.rb +98 -0
- data/lib/supplejack_api.rb +13 -0
- data/lib/supplejack_api/admin/sortable.rb +40 -0
- data/lib/supplejack_api/engine.rb +46 -0
- data/lib/supplejack_api/harvester_constraint.rb +28 -0
- data/lib/supplejack_api/stylesheets.rb +36 -0
- data/lib/supplejack_api/utils.rb +75 -0
- data/lib/supplejack_api/version.rb +11 -0
- data/lib/tasks/resque.rake +22 -0
- data/lib/url_validator.rb +38 -0
- data/spec/controllers/supplejack_api/admin/base_controller_spec.rb +55 -0
- data/spec/controllers/supplejack_api/admin/site_activities_controller_spec.rb +43 -0
- data/spec/controllers/supplejack_api/admin/users_controller_spec.rb +79 -0
- data/spec/controllers/supplejack_api/application_controller_spec.rb +133 -0
- data/spec/controllers/supplejack_api/concepts_controller_spec.rb +83 -0
- data/spec/controllers/supplejack_api/concerns/records_controller_metrics_spec.rb +60 -0
- data/spec/controllers/supplejack_api/harvester/concepts_controller_spec.rb +57 -0
- data/spec/controllers/supplejack_api/harvester/records_controller_spec.rb +138 -0
- data/spec/controllers/supplejack_api/metrics_api_controller_spec.rb +71 -0
- data/spec/controllers/supplejack_api/partners_controller_spec.rb +77 -0
- data/spec/controllers/supplejack_api/records_controller_spec.rb +143 -0
- data/spec/controllers/supplejack_api/set_items_controller_spec.rb +78 -0
- data/spec/controllers/supplejack_api/sources_controller_spec.rb +161 -0
- data/spec/controllers/supplejack_api/status_controller_spec.rb +120 -0
- data/spec/controllers/supplejack_api/user_sets_controller_spec.rb +233 -0
- data/spec/controllers/supplejack_api/users_controller_spec.rb +61 -0
- data/spec/dummy/README.rdoc +268 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +23 -0
- data/spec/dummy/app/assets/stylesheets/application.css +22 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/helpers/application_helper.rb +9 -0
- data/spec/dummy/app/supplejack_api/concept_schema.rb +83 -0
- data/spec/dummy/app/supplejack_api/record_schema.rb +64 -0
- data/spec/dummy/app/supplejack_api/record_schema.txt +66 -0
- data/spec/dummy/app/views/layouts/application.html.erb +23 -0
- data/spec/dummy/app/workers/supplejack_api/clear_index_buffer.rb +32 -0
- data/spec/dummy/app/workers/supplejack_api/flush_old_records_worker.rb +17 -0
- data/spec/dummy/app/workers/supplejack_api/index_buffer.rb +49 -0
- data/spec/dummy/app/workers/supplejack_api/index_source_worker.rb +39 -0
- data/spec/dummy/app/workers/supplejack_api/index_worker.rb +82 -0
- data/spec/dummy/app/workers/supplejack_api/store_user_activity_worker.rb +24 -0
- data/spec/dummy/config.ru +11 -0
- data/spec/dummy/config/application.rb +76 -0
- data/spec/dummy/config/application.yml +31 -0
- data/spec/dummy/config/application.yml.example +36 -0
- data/spec/dummy/config/boot.rb +17 -0
- data/spec/dummy/config/environment.rb +12 -0
- data/spec/dummy/config/environments/development.rb +42 -0
- data/spec/dummy/config/environments/production.rb +76 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +14 -0
- data/spec/dummy/config/initializers/devise.rb +214 -0
- data/spec/dummy/config/initializers/inflections.rb +22 -0
- data/spec/dummy/config/initializers/kaminari_config.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +12 -0
- data/spec/dummy/config/initializers/mongoid.rb +9 -0
- data/spec/dummy/config/initializers/quiet_logger.rb +23 -0
- data/spec/dummy/config/initializers/resque.rb +18 -0
- data/spec/dummy/config/initializers/secret_token.rb +14 -0
- data/spec/dummy/config/initializers/session_store.rb +15 -0
- data/spec/dummy/config/initializers/simple_form.rb +149 -0
- data/spec/dummy/config/initializers/simple_form_foundation.rb +33 -0
- data/spec/dummy/config/initializers/state_machine.rb +8 -0
- data/spec/dummy/config/initializers/sunspot.rb +32 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +17 -0
- data/spec/dummy/config/locales/devise.en.yml +63 -0
- data/spec/dummy/config/locales/en.yml +66 -0
- data/spec/dummy/config/locales/simple_form.en.yml +33 -0
- data/spec/dummy/config/mongoid.travis.yml +34 -0
- data/spec/dummy/config/mongoid.yml +36 -0
- data/spec/dummy/config/resque-pool.yml +18 -0
- data/spec/dummy/config/resque_schedule.yml +12 -0
- data/spec/dummy/config/routes.rb +11 -0
- data/spec/dummy/config/secrets.yml +8 -0
- data/spec/dummy/config/sunspot.yml +38 -0
- data/spec/dummy/db/concepts.json +37 -0
- data/spec/dummy/db/source_authorities.json +116 -0
- data/spec/dummy/public/404.html +35 -0
- data/spec/dummy/public/422.html +35 -0
- data/spec/dummy/public/500.html +34 -0
- data/spec/dummy/public/favicon.ico +8 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr/collection1/conf/elevate.xml +36 -0
- data/spec/dummy/solr/collection1/conf/mapping-FoldToASCII.txt +3813 -0
- data/spec/dummy/solr/collection1/conf/schema.xml +292 -0
- data/spec/dummy/solr/collection1/conf/solrconfig.xml +1780 -0
- data/spec/dummy/solr/collection1/conf/spellings.txt +2 -0
- data/spec/dummy/solr/collection1/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/collection1/conf/synonyms.txt +31 -0
- data/spec/factories/concepts.rb +16 -0
- data/spec/factories/daily_metrics.rb +10 -0
- data/spec/factories/faceted_metrics.rb +25 -0
- data/spec/factories/fragment.rb +14 -0
- data/spec/factories/partners.rb +14 -0
- data/spec/factories/record_interaction.rb +17 -0
- data/spec/factories/records.rb +47 -0
- data/spec/factories/set_interaction.rb +15 -0
- data/spec/factories/source_authorities.rb +19 -0
- data/spec/factories/sources.rb +16 -0
- data/spec/factories/usage_metrics.rb +20 -0
- data/spec/factories/user_activities.rb +14 -0
- data/spec/factories/user_sets.rb +27 -0
- data/spec/factories/users.rb +23 -0
- data/spec/helpers/application_helper_spec.rb +35 -0
- data/spec/models/concept_spec.rb +163 -0
- data/spec/models/fragment_spec.rb +15 -0
- data/spec/models/site_activity_spec.rb +103 -0
- data/spec/models/source_activity_spec.rb +56 -0
- data/spec/models/source_authority_spec.rb +42 -0
- data/spec/models/supplejack_api/api_concept/concept_fragment_spec.rb +189 -0
- data/spec/models/supplejack_api/api_record/record_fragment_spec.rb +189 -0
- data/spec/models/supplejack_api/concept_spec.rb +0 -0
- data/spec/models/supplejack_api/interaction_updaters/all_usage_metric_spec.rb +41 -0
- data/spec/models/supplejack_api/interaction_updaters/set_metrics_spec.rb +32 -0
- data/spec/models/supplejack_api/interaction_updaters/usage_metrics_spec.rb +44 -0
- data/spec/models/supplejack_api/partner_spec.rb +20 -0
- data/spec/models/supplejack_api/record_search_spec.rb +429 -0
- data/spec/models/supplejack_api/record_spec.rb +280 -0
- data/spec/models/supplejack_api/schema_definition_spec.rb +272 -0
- data/spec/models/supplejack_api/search_spec.rb +243 -0
- data/spec/models/supplejack_api/set_item_spec.rb +123 -0
- data/spec/models/supplejack_api/source_spec.rb +22 -0
- data/spec/models/supplejack_api/support/fragment_helpers_spec.rb +216 -0
- data/spec/models/supplejack_api/support/harvestable_spec.rb +177 -0
- data/spec/models/supplejack_api/support/searchable_spec.rb +85 -0
- data/spec/models/supplejack_api/support/storable_spec.rb +18 -0
- data/spec/models/supplejack_api/user_activity_spec.rb +88 -0
- data/spec/models/supplejack_api/user_set_spec.rb +559 -0
- data/spec/models/supplejack_api/user_spec.rb +348 -0
- data/spec/routing/concepts_routing_spec.rb +22 -0
- data/spec/routing/harvester_constraint_spec.rb +66 -0
- data/spec/routing/harvester_routing_spec.rb +51 -0
- data/spec/routing/partner_routing_spec.rb +34 -0
- data/spec/routing/records_routing_spec.rb +26 -0
- data/spec/routing/sets_routing_spec.rb +44 -0
- data/spec/routing/source_routing_spec.rb +38 -0
- data/spec/routing/users_routing_spec.rb +18 -0
- data/spec/serializers/concept_record_serializer_spec.rb +30 -0
- data/spec/serializers/supplejack_api/application_serializer_spec.rb +14 -0
- data/spec/serializers/supplejack_api/concept_search_serializer_spec.rb +34 -0
- data/spec/serializers/supplejack_api/concept_serializer_spec.rb +92 -0
- data/spec/serializers/supplejack_api/record_search_serializer_spec.rb +34 -0
- data/spec/serializers/supplejack_api/record_serializer_spec.rb +271 -0
- data/spec/serializers/supplejack_api/search_serializer_spec.rb +90 -0
- data/spec/serializers/supplejack_api/user_serializer_spec.rb +22 -0
- data/spec/serializers/supplejack_api/user_set_serializer_spec.rb +96 -0
- data/spec/services/metrics_api/v3/api_spec.rb +23 -0
- data/spec/services/metrics_api/v3/endpoints/facets_spec.rb +25 -0
- data/spec/services/metrics_api/v3/endpoints/global_spec.rb +22 -0
- data/spec/services/metrics_api/v3/endpoints/root_spec.rb +49 -0
- data/spec/services/metrics_api/v3/presenters/extended_metadata_spec.rb +49 -0
- data/spec/spec_helper.rb +70 -0
- data/spec/support/api/schemas/metrics/daily_metrics_metadata.json +24 -0
- data/spec/support/api/schemas/metrics/extended_metrics.json +26 -0
- data/spec/support/api/schemas/metrics/extended_response.json +6 -0
- data/spec/support/api/schemas/metrics/facets_response.json +6 -0
- data/spec/support/api/schemas/metrics/record_metadata.json +33 -0
- data/spec/support/api/schemas/metrics/top_level_response.json +6 -0
- data/spec/support/api/schemas/metrics/view_metadata.json +33 -0
- data/spec/support/api_schema_matcher.rb +14 -0
- data/spec/support/devise.rb +10 -0
- data/spec/workers/supplejack_api/daily_metrics_worker_spec.rb +140 -0
- data/spec/workers/supplejack_api/flush_old_records_worker_spec.rb +20 -0
- data/spec/workers/supplejack_api/index_worker_spec.rb +52 -0
- data/spec/workers/supplejack_api/source_index_worker_spec.rb +61 -0
- metadata +1231 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
class IndexWorker
|
10
|
+
@queue = :solr_index
|
11
|
+
|
12
|
+
def self.perform(sunspot_method, object = nil)
|
13
|
+
sunspot_method = sunspot_method.to_sym
|
14
|
+
object = object.with_indifferent_access if object.is_a? Hash
|
15
|
+
|
16
|
+
Rails.logger.level = 1 unless Rails.env.development?
|
17
|
+
|
18
|
+
session = Sunspot.session
|
19
|
+
Sunspot.session = Sunspot::Rails.build_session
|
20
|
+
case sunspot_method
|
21
|
+
when :index
|
22
|
+
self.index(self.find_all(object[:class], object[:id]))
|
23
|
+
when :remove
|
24
|
+
self.remove(self.find_all(object[:class], object[:id]))
|
25
|
+
when :remove_all
|
26
|
+
self.remove_all(object)
|
27
|
+
when :commit_if_dirty
|
28
|
+
self.commit_if_dirty
|
29
|
+
when :commit_if_delete_dirty
|
30
|
+
self.commit_if_delete_dirty
|
31
|
+
when :commit
|
32
|
+
self.commit
|
33
|
+
else
|
34
|
+
raise "Error: undefined protocol for IndexWorker: #{sunspot_method} (#{objects})"
|
35
|
+
end
|
36
|
+
Sunspot.session = session
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.index(object)
|
40
|
+
Sunspot.index(object)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.remove(object)
|
44
|
+
Sunspot.remove(object)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.remove_by_id(klass, id)
|
48
|
+
Sunspot.remove_by_id(klass, id)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.remove_all(klass = nil)
|
52
|
+
klass = klass.constantize unless klass.nil?
|
53
|
+
Sunspot.remove_all(klass)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.commit
|
57
|
+
begin
|
58
|
+
# on production, use autocommit in solrconfig.xml
|
59
|
+
# or commitWithin whenever sunspot supports it
|
60
|
+
sleep(20) unless Rails.env.test? # Sleep 20 seconds to wait for other potential jobs being executed in parallel
|
61
|
+
Sunspot.commit
|
62
|
+
rescue RSolr::Error::Http => e
|
63
|
+
Rails.logger.error e.inspect
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.commit_if_dirty
|
68
|
+
Sunspot.commit_if_dirty
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.commit_if_delete_dirty
|
72
|
+
Sunspot.commit_if_delete_dirty
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.find_all(klass, ids)
|
76
|
+
klass = "SupplejackApi::#{klass}" if klass.deconstantize.blank?
|
77
|
+
object_ids = *ids
|
78
|
+
klass.constantize.where(:id.in => object_ids)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
class StoreUserActivityWorker
|
10
|
+
|
11
|
+
@queue = :user_activity
|
12
|
+
|
13
|
+
def self.perform
|
14
|
+
SupplejackApi::User.all.each do |user|
|
15
|
+
user.user_activities << SupplejackApi::UserActivity.build_from_user(user.daily_activity) unless user.daily_activity_stored
|
16
|
+
user.calculate_last_30_days_requests
|
17
|
+
user.reset_daily_activity
|
18
|
+
user.save
|
19
|
+
end
|
20
|
+
|
21
|
+
SupplejackApi::SiteActivity.generate_activity
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
# This file is used by Rack-based servers to start the application.
|
9
|
+
|
10
|
+
require ::File.expand_path('../config/environment', __FILE__)
|
11
|
+
run Dummy::Application
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
require File.expand_path('../boot', __FILE__)
|
9
|
+
|
10
|
+
# Pick the frameworks you want:
|
11
|
+
# require 'active_record/railtie'
|
12
|
+
require 'action_controller/railtie'
|
13
|
+
require 'action_mailer/railtie'
|
14
|
+
require 'active_resource/railtie'
|
15
|
+
require 'sprockets/railtie'
|
16
|
+
require 'rails/test_unit/railtie'
|
17
|
+
|
18
|
+
Bundler.require
|
19
|
+
require 'supplejack_api'
|
20
|
+
|
21
|
+
module Dummy
|
22
|
+
class Application < Rails::Application
|
23
|
+
# Settings in config/environments/* take precedence over those specified here.
|
24
|
+
# Application configuration should go into files in config/initializers
|
25
|
+
# -- all .rb files in that directory are automatically loaded.
|
26
|
+
|
27
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
28
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
29
|
+
|
30
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
31
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
32
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
33
|
+
|
34
|
+
# Activate observers that should always be running.
|
35
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
36
|
+
|
37
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
38
|
+
# Run 'rake -D time' for a list of tasks for finding time zone names. Default is UTC.
|
39
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
40
|
+
|
41
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
42
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
43
|
+
# config.i18n.default_locale = :de
|
44
|
+
|
45
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
46
|
+
config.encoding = 'utf-8'
|
47
|
+
|
48
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
49
|
+
config.filter_parameters += [:password]
|
50
|
+
|
51
|
+
# Enable escaping HTML in JSON.
|
52
|
+
config.active_support.escape_html_entities_in_json = true
|
53
|
+
|
54
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
55
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
56
|
+
# like if you have constraints or database-specific column types
|
57
|
+
# config.active_record.schema_format = :sql
|
58
|
+
|
59
|
+
# Enforce whitelist mode for mass assignment.
|
60
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
61
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
62
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
63
|
+
# config.active_record.whitelist_attributes = true
|
64
|
+
|
65
|
+
# Enable the asset pipeline
|
66
|
+
config.assets.enabled = true
|
67
|
+
|
68
|
+
config.time_zone = "Wellington"
|
69
|
+
|
70
|
+
# Version of your assets, change this if you want to expire all your assets
|
71
|
+
config.assets.version = '1.0'
|
72
|
+
|
73
|
+
config.i18n.enforce_available_locales = true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
defaults: &defaults
|
9
|
+
SOLR_PING: 'http://localhost:8983/solr/admin/ping'
|
10
|
+
HTTP_HOST: 'http://localhost:3000'
|
11
|
+
WORKER_API_URL: 'http://localhost:3002'
|
12
|
+
DEVISE_MAILER: 'mailer@example.com'
|
13
|
+
HARVESTER_IPS: '127.0.0.1'
|
14
|
+
REQUEST_LIMIT_MAILER: 'develop@example.com'
|
15
|
+
MONGOID_HOSTS: 'localhost:27017'
|
16
|
+
WWW_DOMAIN: 'www.dev'
|
17
|
+
|
18
|
+
development:
|
19
|
+
<<: *defaults
|
20
|
+
|
21
|
+
test:
|
22
|
+
<<: *defaults
|
23
|
+
SOLR_PING: 'http://test.host'
|
24
|
+
HTTP_HOST: 'http://test.host'
|
25
|
+
WWW_DOMAIN: 'test.host'
|
26
|
+
|
27
|
+
staging:
|
28
|
+
<<: *defaults
|
29
|
+
|
30
|
+
production:
|
31
|
+
<<: *defaults
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
defaults: &defaults
|
9
|
+
SOLR_PING: 'http://localhost:8982/solr/admin/ping'
|
10
|
+
HTTP_HOST: 'http://localhost:3000'
|
11
|
+
WORKER_API_URL: 'http://localhost:3002'
|
12
|
+
WWW_DOMAIN: 'www.dev'
|
13
|
+
DEVISE_MAILER: 'mailer@example.com'
|
14
|
+
RESQUE_USER: 'admin'
|
15
|
+
RESQUE_PASS: 'password'
|
16
|
+
HARVESTER_IPS: '127.0.0.1'
|
17
|
+
REQUEST_LIMIT_MAILER: 'develop@digitalnz.org'
|
18
|
+
BLACKLIST_MAILER_TO: 'blacklist@mailer.com'
|
19
|
+
BLACKLIST_MAILER_FROM: 'mailer@blacklist.org'
|
20
|
+
HTTP_HOST: 'http://test.host'
|
21
|
+
MONGOID_HOSTS: 'localhost:27017'
|
22
|
+
|
23
|
+
development:
|
24
|
+
<<: *defaults
|
25
|
+
|
26
|
+
test:
|
27
|
+
<<: *defaults
|
28
|
+
SOLR_PING: 'http://test.host'
|
29
|
+
HTTP_HOST: 'http://test.host'
|
30
|
+
WWW_DOMAIN: 'test.host'
|
31
|
+
|
32
|
+
staging:
|
33
|
+
<<: *defaults
|
34
|
+
|
35
|
+
production:
|
36
|
+
<<: *defaults
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
10
|
+
|
11
|
+
if File.exist?(gemfile)
|
12
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
13
|
+
require 'bundler'
|
14
|
+
Bundler.setup
|
15
|
+
end
|
16
|
+
|
17
|
+
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
# Load the rails application
|
9
|
+
require File.expand_path('../application', __FILE__)
|
10
|
+
|
11
|
+
# Initialize the rails application
|
12
|
+
Dummy::Application.initialize!
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
require 'better_errors'
|
9
|
+
|
10
|
+
Dummy::Application.configure do
|
11
|
+
# Settings specified here will take precedence over those in config/application.rb
|
12
|
+
|
13
|
+
# In the development environment your application's code is reloaded on
|
14
|
+
# every request. This slows down response time but is perfect for development
|
15
|
+
# since you don't have to restart the web server when you make code changes.
|
16
|
+
config.cache_classes = false
|
17
|
+
|
18
|
+
# Log error messages when you accidentally call methods on nil.
|
19
|
+
config.whiny_nils = true
|
20
|
+
|
21
|
+
config.eager_load = false
|
22
|
+
|
23
|
+
# Show full error reports and disable caching
|
24
|
+
config.consider_all_requests_local = true
|
25
|
+
config.action_controller.perform_caching = false
|
26
|
+
|
27
|
+
# Don't care if the mailer can't send
|
28
|
+
config.action_mailer.raise_delivery_errors = false
|
29
|
+
|
30
|
+
# Print deprecation notices to the Rails logger
|
31
|
+
config.active_support.deprecation = :log
|
32
|
+
|
33
|
+
# Only use best-standards-support built into browsers
|
34
|
+
config.action_dispatch.best_standards_support = :builtin
|
35
|
+
|
36
|
+
|
37
|
+
# Do not compress assets
|
38
|
+
config.assets.compress = false
|
39
|
+
|
40
|
+
# Expands the lines which load the assets
|
41
|
+
config.assets.debug = true
|
42
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
Dummy::Application.configure do
|
9
|
+
# Settings specified here will take precedence over those in config/application.rb
|
10
|
+
|
11
|
+
# Code is not reloaded between requests
|
12
|
+
config.cache_classes = true
|
13
|
+
|
14
|
+
# Full error reports are disabled and caching is turned on
|
15
|
+
config.consider_all_requests_local = false
|
16
|
+
config.action_controller.perform_caching = true
|
17
|
+
|
18
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
19
|
+
config.serve_static_assets = true
|
20
|
+
|
21
|
+
# Compress JavaScripts and CSS
|
22
|
+
config.assets.compress = true
|
23
|
+
|
24
|
+
# Don't fallback to assets pipeline if a precompiled asset is missed
|
25
|
+
config.assets.compile = false
|
26
|
+
|
27
|
+
# Generate digests for assets URLs
|
28
|
+
config.assets.digest = true
|
29
|
+
|
30
|
+
config.eager_load = true
|
31
|
+
# Defaults to Rails.root.join("public/assets")
|
32
|
+
# config.assets.manifest = YOUR_PATH
|
33
|
+
|
34
|
+
# Specifies the header that your server uses for sending files
|
35
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
36
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
37
|
+
|
38
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
39
|
+
# config.force_ssl = true
|
40
|
+
|
41
|
+
# See everything in the log (default is :info)
|
42
|
+
config.log_level = :debug
|
43
|
+
|
44
|
+
# Use a different logger for distributed setups
|
45
|
+
# config.logger = SyslogLogger.new
|
46
|
+
|
47
|
+
# Use a different cache store in production
|
48
|
+
config.cache_store = :dalli_store, *ENV['CACHE_STORE'].split(','), { :namespace => 'api', down_retry_delay: 1.hours, socket_timeout: 0.1 }
|
49
|
+
|
50
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
51
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
52
|
+
|
53
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
54
|
+
# config.assets.precompile += %w( search.js )
|
55
|
+
|
56
|
+
# Disable delivery errors, bad email addresses will be ignored
|
57
|
+
# config.action_mailer.raise_delivery_errors = false
|
58
|
+
|
59
|
+
config.action_mailer.default_url_options = { :host => ENV['HOST'] }
|
60
|
+
# ActionMailer Config
|
61
|
+
# Setup for production - deliveries, no errors raised
|
62
|
+
config.action_mailer.delivery_method = :smtp
|
63
|
+
config.action_mailer.perform_deliveries = true
|
64
|
+
config.action_mailer.raise_delivery_errors = false
|
65
|
+
config.action_mailer.default :charset => "utf-8"
|
66
|
+
|
67
|
+
# Enable threaded mode
|
68
|
+
# config.threadsafe!
|
69
|
+
|
70
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
71
|
+
# the I18n.default_locale when a translation can not be found)
|
72
|
+
config.i18n.fallbacks = true
|
73
|
+
|
74
|
+
# Send deprecation notices to registered listeners
|
75
|
+
config.active_support.deprecation = :notify
|
76
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
Dummy::Application.configure do
|
9
|
+
# Settings specified here will take precedence over those in config/application.rb
|
10
|
+
|
11
|
+
# The test environment is used exclusively to run your application's
|
12
|
+
# test suite. You never need to work with it otherwise. Remember that
|
13
|
+
# your test database is "scratch space" for the test suite and is wiped
|
14
|
+
# and recreated between test runs. Don't rely on the data there!
|
15
|
+
config.cache_classes = true
|
16
|
+
|
17
|
+
# Configure static asset server for tests with Cache-Control for performance
|
18
|
+
config.serve_static_assets = true
|
19
|
+
config.static_cache_control = "public, max-age=3600"
|
20
|
+
|
21
|
+
# Log error messages when you accidentally call methods on nil
|
22
|
+
config.whiny_nils = true
|
23
|
+
|
24
|
+
config.eager_load = false
|
25
|
+
|
26
|
+
config.cache_store = :null_store
|
27
|
+
|
28
|
+
# Show full error reports and disable caching
|
29
|
+
config.consider_all_requests_local = true
|
30
|
+
config.action_controller.perform_caching = false
|
31
|
+
|
32
|
+
# Raise exceptions instead of rendering exception templates
|
33
|
+
config.action_dispatch.show_exceptions = false
|
34
|
+
|
35
|
+
# Disable request forgery protection in test environment
|
36
|
+
config.action_controller.allow_forgery_protection = false
|
37
|
+
|
38
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
39
|
+
# The :test delivery method accumulates sent emails in the
|
40
|
+
# ActionMailer::Base.deliveries array.
|
41
|
+
config.action_mailer.delivery_method = :test
|
42
|
+
|
43
|
+
|
44
|
+
# Print deprecation notices to the stderr
|
45
|
+
config.active_support.deprecation = :stderr
|
46
|
+
end
|