source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151130062219_create_question_items.rb
Ruby
mit
19
develop
270
class CreateQuestionItems < ActiveRecord::Migration[4.2] def change create_table :question_items do |t| t.string :label t.string :literal t.references :instruction, index: true, foreign_key: true t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20170517153047_create_item_groups.rb
Ruby
mit
19
develop
267
class CreateItemGroups < ActiveRecord::Migration[5.0] def change create_table :item_groups do |t| t.integer :group_type t.string :item_type t.string :label t.references :root_item, polymorphic: true t.timestamps end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20240425130950_update_functions_for_construct_ddi_slug.rb
Ruby
mit
19
develop
16,781
class UpdateFunctionsForConstructDdiSlug < ActiveRecord::Migration[6.1] def change reversible do |dir| dir.up do execute <<~SQL -- -- Name: update_cc_condition(); Type: FUNCTION; Schema: public; Owner: - -- CREATE OR REPLACE FUNCTION public.update_cc_conditio...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20170605112157_create_construct_views.rb
Ruby
mit
19
develop
33,738
class CreateConstructViews < ActiveRecord::Migration[5.0] def change reversible do |dir| dir.up do execute <<~SQL ALTER TABLE cc_conditions RENAME TO conditions; ALTER SEQUENCE cc_conditions_id_seq RENAME TO conditions_id_seq; ALTER TABLE cc_loops RENAME TO loops; ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151206205100_create_instruments_datasets.rb
Ruby
mit
19
develop
321
class CreateInstrumentsDatasets < ActiveRecord::Migration[4.2] def change create_table :instruments_datasets do |t| t.references :instrument, index: true, foreign_key: true, null: false t.references :dataset, index: true, foreign_key: true, null: false t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151201095143_create_cc_loops.rb
Ruby
mit
19
develop
250
class CreateCcLoops < ActiveRecord::Migration[4.2] def change create_table :cc_loops do |t| t.string :loop_var t.string :start_val t.string :end_val t.string :loop_while t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20170601154431_create_view_of_control_constructs_with_topic.rb
Ruby
mit
19
develop
571
class CreateViewOfControlConstructsWithTopic < ActiveRecord::Migration[5.0] def change reversible do |dir| dir.up do execute <<~SQL CREATE VIEW cc_links AS ( SELECT cc.*, l.topic_id FROM control_constructs AS cc LEFT OUTER JOIN links AS l ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151206165603_create_variables.rb
Ruby
mit
19
develop
379
class CreateVariables < ActiveRecord::Migration[4.2] def change create_table :variables do |t| t.string :name, null: false t.string :label t.string :var_type, null: false t.references :dataset, index: true, foreign_key: true, null: false t.timestamps null: false end add_inde...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160603113436_add_confirmable_and_lockable.rb
Ruby
mit
19
develop
552
class AddConfirmableAndLockable < ActiveRecord::Migration[4.2] def change add_column :users, :confirmation_token, :string add_column :users, :confirmed_at, :datetime add_column :users, :confirmation_sent_at, :datetime add_column :users, :unconfirmed_email, :string add_column :users, :failed_attem...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160413100019_devise_create_users.rb
Ruby
mit
19
develop
1,538
class DeviseCreateUsers < ActiveRecord::Migration[4.2] def change create_table(:users) do |t| ## Database authenticatable t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default: "" ## Recoverable t.string :reset_password_token ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151129204903_create_codes.rb
Ruby
mit
19
develop
311
class CreateCodes < ActiveRecord::Migration[4.2] def change create_table :codes do |t| t.string :value t.integer :order t.references :code_list, index: true, foreign_key: true t.references :catagory, index: true, foreign_key: true t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20190829124508_create_imports.rb
Ruby
mit
19
develop
298
class CreateImports < ActiveRecord::Migration[5.0] def change create_table :imports do |t| t.references :document, foreign_key: true t.string :import_type t.references :dataset, foreign_key: true t.string :state t.text :log t.timestamps end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160805093216_defer_all_constraints.rb
Ruby
mit
19
develop
4,966
class DeferAllConstraints < ActiveRecord::Migration[5.0] def change reversible do |dir| dir.up do execute <<-SQL ALTER TABLE cc_questions DROP CONSTRAINT encapsulate_cc_questions_and_response_units; ALTER TABLE codes DROP CONSTRAINT encapsulate_codes_and_cate...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151130142555_create_response_domain_numerics.rb
Ruby
mit
19
develop
272
class CreateResponseDomainNumerics < ActiveRecord::Migration[4.2] def change create_table :response_domain_numerics do |t| t.string :numeric_type t.string :label t.decimal :min t.decimal :max t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151206185659_create_links.rb
Ruby
mit
19
develop
430
class CreateLinks < ActiveRecord::Migration[4.2] def change create_table :links do |t| t.references :target, polymorphic: true, index: true, null: false t.references :topic, index: true, foreign_key: true, null: false t.integer :x t.integer :y t.timestamps null: false end ad...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20240207154741_add_slugs.rb
Ruby
mit
19
develop
1,235
class AddSlugs < ActiveRecord::Migration[6.1] def up # Tables to update, including :instruments tables = [:categories, :code_lists, :codes, :control_constructs, :identifiers, :instructions, :question_items, :question_grids, :instruments] # Add ddi_slug columns and indexes tables.each do |table| ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151130062608_create_question_grids.rb
Ruby
mit
19
develop
785
class CreateQuestionGrids < ActiveRecord::Migration[4.2] def change create_table :question_grids do |t| t.string :label t.string :literal t.references :instruction, index: true, foreign_key: true t.integer :vertical_code_list_id, index: true t.integer :horizontal_code_list_id, index:...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160930113839_create_documents.rb
Ruby
mit
19
develop
353
class CreateDocuments < ActiveRecord::Migration[5.0] def change create_table :documents do |t| t.string :filename t.string :content_type t.binary :file_contents t.string :md5_hash, limit: 32 t.references :item, polymorphic: true t.timestamps end add_index :documents, :...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20240208160611_add_slugs_for_constructs.rb
Ruby
mit
19
develop
43,964
class AddSlugsForConstructs < ActiveRecord::Migration[6.1] def up execute "DROP VIEW IF EXISTS public.cc_conditions CASCADE;" # Recreate cc_conditions with ddi_slug execute %Q| CREATE VIEW public.cc_conditions AS SELECT con.id, con.instrument_id, con.literal, con.logic,...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20260421155655_add_filename_to_imports.rb
Ruby
mit
19
develop
364
# frozen_string_literal: true class AddFilenameToImports < ActiveRecord::Migration[6.1] def up add_column :imports, :filename, :string execute <<~SQL UPDATE imports SET filename = documents.filename FROM documents WHERE imports.document_id = documents.id SQL end def down ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20201021193720_add_signed_off_to_instruments.rb
Ruby
mit
19
develop
215
class AddSignedOffToInstruments < ActiveRecord::Migration[5.2] def change unless column_exists? :instruments, :signed_off add_column :instruments, :signed_off, :boolean, default: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151130062018_create_rds_qs.rb
Ruby
mit
19
develop
273
class CreateRdsQs < ActiveRecord::Migration[4.2] def change create_table :rds_qs do |t| t.references :response_domain, polymorphic: true, index: true t.references :question, polymorphic: true, index: true t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151206185120_create_maps.rb
Ruby
mit
19
develop
433
class CreateMaps < ActiveRecord::Migration[4.2] def change create_table :maps do |t| t.references :source, polymorphic: true, index: true, null: false t.references :variable, index: true, foreign_key: true, null: false t.integer :x t.integer :y t.timestamps null: false end a...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160716150053_add_order_to_rds_qs.rb
Ruby
mit
19
develop
517
class AddOrderToRdsQs < ActiveRecord::Migration[4.2] def change add_column :rds_qs, :rd_order, :integer reversible do |dir| dir.up do execute <<-SQL ALTER TABLE rds_qs ADD CONSTRAINT unique_for_rd_order_within_question UNIQUE (question_id, question_type, rd_order);...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20161209155519_unique_mapping.rb
Ruby
mit
19
develop
274
class UniqueMapping < ActiveRecord::Migration[5.0] def change add_index :maps, %i(source_id variable_id), unique: true, where: 'source_type = \'Variable\'' add_index :maps, %i(source_id variable_id x y), unique: true, where: 'source_type = \'Question\'' end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20171212182936_make_prefix_unique.rb
Ruby
mit
19
develop
283
class MakePrefixUnique < ActiveRecord::Migration[5.0] def change reversible do |dir| dir.up do change_column :instruments, :prefix, :string, unique: true end dir.down do change_column :instruments, :prefix, :string end end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151130063811_create_instruments.rb
Ruby
mit
19
develop
269
class CreateInstruments < ActiveRecord::Migration[4.2] def change create_table :instruments do |t| t.string :agency t.string :version t.string :prefix t.string :label t.string :study t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160712131146_add_instrument_encapsulation.rb
Ruby
mit
19
develop
10,604
class AddInstrumentEncapsulation < ActiveRecord::Migration[4.2] def change reversible do |dir| dir.up do add_column :cc_conditions, :construct_type, :string, null: :false, default: 'CcCondition' add_column :cc_loops, :construct_type, :string, null: :false, default: 'CcLoop' ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151204193654_add_not_null_foreign_keys.rb
Ruby
mit
19
develop
1,084
class AddNotNullForeignKeys < ActiveRecord::Migration[4.2] def change change_column :codes, :category_id, :integer, null: false change_column :codes, :code_list_id, :integer, null: false change_column :response_domain_codes, :code_list_id, :integer, null: false change_column :rds_qs, :question_id, :in...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151130143016_create_response_domain_datetimes.rb
Ruby
mit
19
develop
256
class CreateResponseDomainDatetimes < ActiveRecord::Migration[4.2] def change create_table :response_domain_datetimes do |t| t.string :datetime_type t.string :label t.string :format t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20161213091354_create_mapper_views.rb
Ruby
mit
19
develop
1,068
class CreateMapperViews < ActiveRecord::Migration[5.0] def change reversible do |dir| dir.up do execute <<~SQL CREATE VIEW qv_mappings AS ( SELECT row_number() OVER () as id, COALESCE(cc.label, '0') as question, v.name as variable, m.x, m.y, qc.instrument_id, v.dataset_id FROM va...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20241124224933_create_exports.rb
Ruby
mit
19
develop
384
class CreateExports < ActiveRecord::Migration[6.1] def change create_table :exports do |t| t.references :document, foreign_key: true, null: true t.string :export_type t.references :dataset, foreign_key: true, null: true t.references :instrument, foreign_key: true, null: true t.string...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20171124115905_adding_ancestoral_topic_materialized_view.rb
Ruby
mit
19
develop
1,603
class AddingAncestoralTopicMaterializedView < ActiveRecord::Migration[5.0] def change reversible do |dir| dir.up do execute <<~SQL CREATE MATERIALIZED VIEW ancestral_topic AS ( WITH RECURSIVE cc_tree AS ( SELECT ccl.*, 1 AS level FROM cc_links ccl UNION ALL ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151201095347_create_cc_questions.rb
Ruby
mit
19
develop
217
class CreateCcQuestions < ActiveRecord::Migration[4.2] def change create_table :cc_questions do |t| t.references :question, polymorphic: true, index: true t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20190813092806_add_slug_to_instruments.rb
Ruby
mit
19
develop
295
class AddSlugToInstruments < ActiveRecord::Migration[5.0] def change unless column_exists? :instruments, :slug add_column :instruments, :slug, :string add_index :instruments, :slug, unique: true end Instrument.find_each{|i| i.update_column(:slug, i.prefix)} end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151206165407_create_datasets.rb
Ruby
mit
19
develop
242
class CreateDatasets < ActiveRecord::Migration[4.2] def change create_table :datasets do |t| t.string :name, null: false, unique: true t.string :doi t.string :filename t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151201094202_create_control_constructs.rb
Ruby
mit
19
develop
483
class CreateControlConstructs < ActiveRecord::Migration[4.2] def change create_table :control_constructs do |t| t.string :label t.references :construct, polymorphic: true, index: true t.integer :parent_id, index: true # t.references :parent, index: true, foreign_key: true t.integer :p...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151206110030_add_instrument_references_to_everything_but_junctions.rb
Ruby
mit
19
develop
1,136
class AddInstrumentReferencesToEverythingButJunctions < ActiveRecord::Migration[4.2] def change add_reference :categories, :instrument, index: true, null: false add_reference :code_lists, :instrument, index: true, null: false add_reference :response_domain_datetimes, :instrument, index: true, null: false ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151129205538_create_response_domain_codes.rb
Ruby
mit
19
develop
235
class CreateResponseDomainCodes < ActiveRecord::Migration[4.2] def change create_table :response_domain_codes do |t| t.references :code_list, index: true, foreign_key: true t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20161027133806_add_question_label_constraints.rb
Ruby
mit
19
develop
493
class AddQuestionLabelConstraints < ActiveRecord::Migration[5.0] def change change_column_null :question_items, :label, false change_column_null :question_grids, :label, false add_index :question_grids, [:label, :instrument_id], unique: true unless index_exists?(:question_grids, [:label, :instrument_id],...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160413095800_create_groups.rb
Ruby
mit
19
develop
210
class CreateGroups < ActiveRecord::Migration[4.2] def change create_table :groups do |t| t.string :type t.string :label t.string :study t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20170519102218_create_groupings.rb
Ruby
mit
19
develop
1,444
class CreateGroupings < ActiveRecord::Migration[5.0] def change create_table :streamlined_groupings do |t| t.references :item_group, foreign_key: true, null: false t.integer :item_id, null: false, foreign_ke: true t.timestamps end reversible do |dir| dir.up do execute <<~...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160913201152_add_unique_labels_within_instrument.rb
Ruby
mit
19
develop
661
class AddUniqueLabelsWithinInstrument < ActiveRecord::Migration[5.0] def change add_index :control_constructs, [:label, :instrument_id], unique: true add_index :code_lists, [:label, :instrument_id], unique: true add_index :categories, [:label, :instrument_id], unique: true add_index :instructions, [:t...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20151129205758_create_response_domain_texts.rb
Ruby
mit
19
develop
219
class CreateResponseDomainTexts < ActiveRecord::Migration[4.2] def change create_table :response_domain_texts do |t| t.string :label t.integer :maxlen t.timestamps null: false end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
db/migrate/20160808100337_add_response_cardinality.rb
Ruby
mit
19
develop
261
class AddResponseCardinality < ActiveRecord::Migration[5.0] def change add_column :response_domain_codes, :min_responses, :integer, default: 1, null: false add_column :response_domain_codes, :max_responses, :integer, default: 1, null: false end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers.rb
Ruby
mit
19
develop
758
module Importers module Controller extend ActiveSupport::Concern included do def member_imports imports = params[:imports].nil? ? [] : params[:imports] head :ok, format: :json if imports.empty? begin imports.each do |import| doc = Document.new file: import[:...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/cache.rb
Ruby
mit
19
develop
1,554
module Cache module Instrument CACHE_METHODS = [ :question_items, :question_grids, :cc_conditions, :cc_loops, :cc_questions, :cc_sequences, :cc_statements ] module Setting extend ActiveSupport::Concern included do Cache::Instrumen...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/util.rb
Ruby
mit
19
develop
227
module Util def self.question_label(name) chunks = name.sub(/^q[cig]_/,'').sub(/_/, ' ').split(/_/) if chunks.length > 1 return chunks[0] + '(' + chunks[1] + ')' else return chunks[0] end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/linkable_parent.rb
Ruby
mit
19
develop
1,081
module LinkableParent extend ActiveSupport::Concern included do has_one :link, as: :target, dependent: :destroy has_one :topic, through: :link def find_closest_ancestor begin <<~SQL WITH constructs_selection AS ( SELECT * FROM cc_links WHERE c...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/linkable.rb
Ruby
mit
19
develop
1,283
module Linkable module Model extend ActiveSupport::Concern included do has_one :link, as: :target, dependent: :destroy has_one :topic, through: :link def get_ancestral_topic if self.respond_to? :resolved_topic self.resolved_topic elsif self.respond_to? :find_closes...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/data_tools.rb
Ruby
mit
19
develop
565
module DataTools class << self def similar_strands(datasets) datasets = datasets.to_a first = datasets.shift output = [] first.variables.find_each do |v| output << { 0 => v.name } datasets.each_with_index do |dataset, i| fz = FuzzyMatch.new(dataset.variables, rea...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/response_domain.rb
Ruby
mit
19
develop
534
module ResponseDomain extend ActiveSupport::Concern included do has_many :rds_qs, class_name: 'RdsQs', as: :response_domain, dependent: :destroy has_many :question_items, through: :rds_qs, source: :question, source_type: 'QuestionItem' has_many :question_grids, through: :rds_qs, source: :question, sourc...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/rd_subtype_shim.rb
Ruby
mit
19
develop
475
module RdSubtypeShim extend ActiveSupport::Concern included do before_action :subtype_shim, only: [:create, :update] def subtype_shim self.params[ self .class .model_class .name .underscore .to_sym ][subtype] = self....
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/question.rb
Ruby
mit
19
develop
4,616
module Question end module Question::Model extend ActiveSupport::Concern included do belongs_to :instrument belongs_to :instruction has_many :rds_qs, class_name: 'RdsQs', as: :question, dependent: :destroy has_many :response_domain_codes, through: :rds_qs, source: :response_domain, source_type: 'Re...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/identifiable.rb
Ruby
mit
19
develop
1,120
module Identifiable extend ActiveSupport::Concern included do has_many :identifiers, as: :item, dependent: :destroy def self.find_by_identifier(id_type, value) cache_result = $redis.hget 'identifiers', id_type + ':' + value.to_s if cache_result.nil? Identifier.includes(:item).where(item...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exportable.rb
Ruby
mit
19
develop
1,333
module Exportable extend ActiveSupport::Concern class_methods do def tag [self::NS, self::TYPE].join ':' end end included do after_commit :set_ddi_slug, on: :create def urn=(value) return unless value value.match(/urn:ddi:(?<instrument_agency>.*):(?<instrument_prefix>.*)-(?...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/loggable.rb
Ruby
mit
19
develop
929
module Exporters::Loggable extend ActiveSupport::Concern included do def set_export_to_running return unless @export @export.update(state: :running) broadcast_progress("Export started") @logs = [] @log_entry = {} @errors = false end def set_export_to_finished ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/dataset.rb
Ruby
mit
19
develop
2,608
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::Dataset} # # {::Dataset} is a direct alias of DDI 3.2 Dataset. # # This is not a real exporter, it actually performs transformations # on the file imported and held in the database as a Document. # # @see ::Dataset class Dataset # Exports th...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/question_grid.rb
Ruby
mit
19
develop
5,108
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::QuestionGrid} # # {::QuestionGrid} is a direct alias of DDI 3.2 QuestionItem. # # === Example # doc = Nokogiri::XML::Document.new # qg = QuestionGrid.first # exporter = Exporters::XML::DDI::QuestionGrid.new doc # xml_node = exporter.V3_2...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/instrument.rb
Ruby
mit
19
develop
9,893
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::Instrument} # # {::Instrument} is a direct alias of DDI 3.2 Instrument. # # @example Exporting to file # i = Instrument.first # exp = Exporters::XML::DDI::Instrument.new # exp.add_root_attributes # filepath = exp.run i # # @example E...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/cc_question.rb
Ruby
mit
19
develop
1,723
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::CcQuestion} # # {::CcQuestion} is a direct alias of DDI 3.2 QuestionConstruct. # # === Example # doc = Nokogiri::XML::Document.new # qc = CcQuestion.first # exporter = Exporters::XML::DDI::CcQuestion.new doc # xml_node = exporter.V3_2(qc...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/cc_statement.rb
Ruby
mit
19
develop
1,582
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::CcStatement} # # {::CcStatement} is a direct alias of DDI 3.2 StatementItem. # # === Example # doc = Nokogiri::XML::Document.new # sta = CcStatement.first # exporter = Exporters::XML::DDI::CcStatement.new doc # xml_node = exporter.V3_2(s...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/cc_condition.rb
Ruby
mit
19
develop
3,502
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::CcCondition} # # {::CcCondition} is a direct alias of DDI 3.2 IfThenElse. # # === Example # doc = Nokogiri::XML::Document.new # con = CcCondition.first # exporter = Exporters::XML::DDI::CcCondition.new doc # xml_node = exporter.V3_2(con)...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/question.rb
Ruby
mit
19
develop
2,858
module Exporters::XML::DDI # Base class for exporting DDI questions class Question < DdiExporterBase # Performs the generic functions for exporting a question # in DDI 3.2 # # @param [Question::Model|Integer] id Either the question or question ID for exporting # @return [Nokogiri::XML::Node] New...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/cc_sequence.rb
Ruby
mit
19
develop
1,671
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::CcSequence} # # {::CcSequence} is a direct alias of DDI 3.2 Sequence. # # === Example # doc = Nokogiri::XML::Document.new # seq = CcSequence.first # exporter = Exporters::XML::DDI::CcSequence.new doc # xml_node = exporter.V3_2(seq) # ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/ddi_exporter_base.rb
Ruby
mit
19
develop
1,419
module Exporters::XML::DDI # Base DDI Exporter abstract class # # This class provides useful methods for all versions of DDI # XML export. # # Instance variable @urn_prefix can be set in derived exporters to overload the default functionality class DdiExporterBase # Sets the XML document for exporting...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/code_list.rb
Ruby
mit
19
develop
1,708
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::CodeList} # # {::CodeList} is a direct alias of DDI 3.2 CodeList. # # === Example # doc = Nokogiri::XML::Document.new # cl = CodeList.first # exporter = Exporters::XML::DDI::CodeList.new doc # xml_node = exporter.V3_2(cl) # # @see ::...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/cc_loop.rb
Ruby
mit
19
develop
3,456
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::CcLoop} # # {::CcLoop} is a direct alias of DDI 3.2 Loop. # # === Example # doc = Nokogiri::XML::Document.new # loop = CcLoop.first # exporter = Exporters::XML::DDI::CcLoop.new doc # xml_node = exporter.V3_2(loop) # # @see ::CcLoop ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/category.rb
Ruby
mit
19
develop
1,435
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::Category} # # {::Category} is a direct alias of DDI 3.2 Category. # # === Example # doc = Nokogiri::XML::Document.new # cat = Category.first # exporter = Exporters::XML::DDI::Category.new doc # xml_node = exporter.V3_2(cat) # # @see ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/instruction.rb
Ruby
mit
19
develop
1,322
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::Instruction} # # {::Instruction} is a direct alias of DDI 3.2 InterviewerInstruction. # # === Example # doc = Nokogiri::XML::Document.new # instruc = Instruction.first # exporter = Exporters::XML::DDI::Instruction.new doc # xml_node = ex...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/fragment.rb
Ruby
mit
19
develop
982
module Exporters::XML::DDI # Static class to wrap DDI node exports into correctly formatted # fragments module Fragment class << self # Exports DDI 3.2 Fragment # # @param [DdiExporterBase] exporter_klass DDI node exporter class to use # @param [Exportable] obj Item for exporting ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/question_item.rb
Ruby
mit
19
develop
2,421
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::QuestionItem} # # {::QuestionItem} is a direct alias of DDI 3.2 QuestionItem. # # === Example # doc = Nokogiri::XML::Document.new # qi = QuestionItem.first # exporter = Exporters::XML::DDI::QuestionItem.new doc # xml_node = exporter.V3_2...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/exporters/xml/ddi/instrument_complete.rb
Ruby
mit
19
develop
8,815
module Exporters::XML::DDI # DDI 3.2 XML Exporter for {::Instrument} # # {::Instrument} is a direct alias of DDI 3.2 Instrument. # # @example Exporting to file # i = Instrument.first # exp = Exporters::XML::DDI::Instrument.new # exp.add_root_attributes # filepath = exp.run i # # @example E...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/loggable.rb
Ruby
mit
19
develop
681
module Importers::Loggable extend ActiveSupport::Concern included do def set_import_to_running return unless @import @import.update(state: :running) @logs = [] @log_entry = {} @errors = false end def set_import_to_finished return unless @import @import.update(...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/txt.rb
Ruby
mit
19
develop
2,616
module Importers::TXT class Basic def initialize(thing, options) begin if thing.is_a? String @doc = open(thing) { |f| Importers::TXT::TabDelimited.new(f) } else document = ::Document.find thing @doc = Importers::TXT::TabDelimited.new document.file_contents ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/txt/whii/code_list.rb
Ruby
mit
19
develop
470
class Importers::TXT::WHII::CodeList < Importers::TXT::Basic def import @doc.each do |name, values| next if name.nil? || values.nil? || name.empty? || values.empty? cl = @object.code_lists.create label: name codes = values[0...-1].split ';' codes.each do |code| code_value, code_la...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/txt/mapper/topic_v.rb
Ruby
mit
19
develop
2,095
class Importers::TXT::Mapper::TopicV < Importers::TXT::Mapper::Dataset def import(options = {}) variable_ids_to_delete = @object.variables.pluck(:id) set_import_to_running vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic) @doc.each do |dataset, v, t| log :inpu...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/txt/mapper/mapping.rb
Ruby
mit
19
develop
3,815
class Importers::TXT::Mapper::Mapping < Importers::TXT::Mapper::Instrument def initialize(thing, options) super(thing, options) @variables_hash = @object.datasets.each_with_object({}) do |dataset, hash| hash[dataset.instance_name] = dataset.variables end end def import(options = {}) Map.whe...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/txt/mapper/topic_q.rb
Ruby
mit
19
develop
2,019
class Importers::TXT::Mapper::TopicQ < Importers::TXT::Mapper::Instrument def import(options = {}) cc_question_ids_to_delete = @object.cc_questions.pluck(:id) set_import_to_running @doc.each do |control_construct_scheme, q, t| log :input, "#{control_construct_scheme},#{q},#{t}" begin i...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/txt/mapper/dv.rb
Ruby
mit
19
develop
2,269
class Importers::TXT::Mapper::DV < Importers::TXT::Mapper::Dataset def import(options = {}) set_import_to_running vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic) begin @doc.each do |variable_dataset, v, source_dataset, s| log :input, "#{variable_data...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/qsrx/specification.rb
Ruby
mit
19
develop
825
module Importers::XML::QSRX class Specification < ParentalImporter def initialize(thing) if thing.is_a? String @doc = open(thing) { |f| Nokogiri::XML(f) } else document = Document.find thing @doc = Nokogiri::XML document.file_contents end @doc.remove_namespaces! ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/qsrx/branch.rb
Ruby
mit
19
develop
461
module Importers::XML::QSRX class Branch < ParentalImporter def XML_node(node) @node = node.at_xpath('./if') @@condition_counter += 1 condition = @instrument.cc_conditions.new( label: 'c_' + @@condition_counter.to_s, literal: @node.at_xpath('./condition')&.content.to_s, ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/qsrx/loop.rb
Ruby
mit
19
develop
265
module Importers::XML::QSRX class Loop < ParentalImporter def XML_node(node) @node = node loop = @instrument.cc_loops.new( label: @node.at_xpath('./context')&.content ) loop.save! read_children(loop) end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/qsrx/module.rb
Ruby
mit
19
develop
367
module Importers::XML::QSRX class Module < ParentalImporter def XML_node(node) @node = node sequence = @instrument.cc_sequences.new( label: @node.at_xpath('./context')&.content, literal: @node.at_xpath('./rm_properties/label')&.content ) sequence.save! read_child...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/qsrx/parental_importer.rb
Ruby
mit
19
develop
3,682
module Importers::XML::QSRX class ParentalImporter @@statement_counter = 0 @@condition_counter = 0 def initialize(instrument) @instrument = instrument end protected def method_missing(m, *args, &block) m.slice(0..4) Rails.logger.warn "QSRX importer does not support #{m} tag...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/ddi_importer_base.rb
Ruby
mit
19
develop
919
module Importers::XML::DDI class DdiImporterBase include ::Importers::Loggable private def compose_urn(agency_node, id_node, version_node) 'urn:ddi:%{agency}:%{id}:%{version}' % { agency: agency_node&.content, id: id_node&.content, version: version_node&.conten...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/question.rb
Ruby
mit
19
develop
7,290
module Importers::XML::DDI class Question < DdiImporterBase RESPONSE_DOMAIN_XPATH = './CodeDomain|./NumericDomain|./TextDomain|./DateTimeDomain' STRUCTURED_RESPONSE_DOMAIN_XPATH = './StructuredMixedResponseDomain/ResponseDomainInMixed/CodeDomain|./StructuredMixedResponseDomain/ResponseDomainInMixed/NumericDom...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/instrument.rb
Ruby
mit
19
develop
11,845
module Importers::XML::DDI class Instrument < DdiImporterBase def initialize(thing, options = {}) if thing.is_a? String @doc = open(thing) { |f| Nokogiri::XML(f) } else document = Document.find thing @doc = Nokogiri::XML document.file_contents end @doc.remove_namesp...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/fragment_instance.rb
Ruby
mit
19
develop
10,043
module Importers::XML::DDI class FragmentInstance attr_accessor :questions, :errors def initialize(xml_fragment, instrument) @xml_fragment = xml_fragment @node = Nokogiri(xml_fragment) @node = @node.remove_namespaces! @instrument = instrument @urn_to_object_mapping = {} s...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/validation_error.rb
Ruby
mit
19
develop
212
module Importers::XML::DDI class ValidationError < ActiveRecord::RecordInvalid attr_accessor :input def initialize(input = '', record = nil) @input = input super(record) end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/instruction.rb
Ruby
mit
19
develop
707
module Importers::XML::DDI class Instruction < DdiImporterBase def initialize(instrument) @instrument = instrument end def XML_node(node) instruction = ::Instruction.new({urn: extract_urn_identifier(node), text: node.at_xpath('./InstructionText/LiteralText/Text').content}) begin ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/code_list.rb
Ruby
mit
19
develop
1,437
module Importers::XML::DDI class CodeList < DdiImporterBase def initialize(instrument) @instrument = instrument end def XML_node(node) codes_to_add = [] node.xpath('./Code').each_with_index do |code, i| begin co = ::Code.new ({ urn: extract_urn_identifier...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/dataset.rb
Ruby
mit
19
develop
1,915
module Importers::XML::DDI class Dataset < DdiImporterBase def initialize(thing, options = {}) if thing.is_a? String @doc = open(thing) { |f| Nokogiri::XML(f) } @filepath = thing else @document = Document.find thing @doc = Nokogiri::XML @document.file_contents @...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/importers/xml/ddi/category.rb
Ruby
mit
19
develop
735
module Importers::XML::DDI class Category < DdiImporterBase def initialize(instrument) @instrument = instrument end def XML_node(node) begin cat = ::Category.new urn: extract_urn_identifier(node), label: node.at_xpath('./Label/Content').content rescue cat = ::Category.ne...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/document_cleanup.rake
Ruby
mit
19
develop
3,070
namespace :documents do desc "Clean up old documents" task cleanup: :environment do puts "Starting document cleanup..." # Show summary first summary = Document.import_export_summary puts "Current state:" puts " Total documents: #{summary[:documents][:total]}" puts " Safe to delete: #{...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/loader.rake
Ruby
mit
19
develop
3,108
desc 'Loads instrument' task :load_instruments => :environment do Dir.chdir ENV['LOAD_PATH'] files = Dir.entries(".").reject { |x| x[0,1] == "." } files.each do |file| if File.exist? file im = Importers::XML::DDI::Instrument.new file im.import end end end desc 'Loads dataset' task :lo...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/similar.rake
Ruby
mit
19
develop
1,177
desc 'Find similar variables' task :similar_variables => :environment do filename = 'C:/CLOSER/Code/archivist/nounlist.txt' if File.exist? filename f = File.open filename nouns = f.read f.close groups = {} total = nouns.lines.count / 100.0 counter = 0 nouns.lines.each do |noun| ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/erd.rake
Ruby
mit
19
develop
680
desc 'Generate Entity Relationship Diagram but without Instrument' task :generate_erd_woi do system "erd --inheritance --exclude=Instrument --filetype=dot --notation=bachman --orientation=horizontal --direct --attributes=foreign_keys,content" system "dot -Tpng erd.dot > app/assets/images/diagrams/erd-woi.png"...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/time.rake
Ruby
mit
19
develop
962
desc 'Time question_items caching' task :question_items => :environment do Instrument.all.each do end beginning_time = Time.now Instrument.all.each do |i| qis = i.question_items end end_time = Time.now puts "Time elapsed #{(end_time - beginning_time)*1000} milliseconds for standard\n" beginnin...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/util.rake
Ruby
mit
19
develop
2,479
desc 'Clear Archivist\'s tmp files (uploads)' task :clear_task do directories = [ 'public/assets', 'public/assets/templates/**' ] directories.each do |directory| puts directory begin if directory[-2..-1] == '**' recursive = true directory = directory[0...-2] else ...