-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Move the record population out of migrations and into db/seeds.rb - Splits the migrations into three separate files, one per model - Add two indices on the linking model, from each direction - Removes the confidence value from the Detector model, leaving only the one on the DetectorCategory linking model
- Loading branch information
1 parent
57b3959
commit b770c25
Showing
8 changed files
with
79 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,11 @@ | ||
class CreateCategories < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :detectors do |t| | ||
t.string :name | ||
t.float :confidence | ||
|
||
t.timestamps | ||
end | ||
add_index :detectors, :name, unique: true | ||
|
||
create_table :categories do |t| | ||
t.string :name | ||
t.text :description | ||
|
||
t.timestamps | ||
end | ||
add_index :categories, :name, unique: true | ||
|
||
create_table :detector_categories do |t| | ||
t.belongs_to :detector, null: false, foreign_key: true | ||
t.belongs_to :category, null: false, foreign_key: true | ||
t.float :confidence | ||
|
||
t.timestamps | ||
end | ||
|
||
Detector.create(name: 'DOI', confidence: 0.95) | ||
Detector.create(name: 'ISBN', confidence: 0.8) | ||
Detector.create(name: 'ISSN', confidence: 0.6) | ||
Detector.create(name: 'PMID', confidence: 0.95) | ||
Detector.create(name: 'Journal', confidence: 0.2) | ||
Detector.create(name: 'SuggestedResource', confidence: 0.95) | ||
|
||
Category.create(name: 'Informational', description: 'A type of search where the user is looking for broad information, rather than an individual item. Also known as "open-ended" or "topical".') | ||
Category.create(name: 'Navigational', description: 'A type of search where the user has a location in mind, and wants to go there. In library discovery, this should mean a URL that will not be in the searched index.') | ||
Category.create(name: 'Transactional', description: 'A type of search where the user has an item in mind, and wants to get that item. Also known as "known-item".') | ||
|
||
DetectorCategory.create(detector: Detector.find_by(name: 'DOI'), category: Category.find_by(name: 'Transactional'), confidence: 0.95) | ||
DetectorCategory.create(detector: Detector.find_by(name: 'ISBN'), category: Category.find_by(name: 'Transactional'), confidence: 0.95) | ||
DetectorCategory.create(detector: Detector.find_by(name: 'ISSN'), category: Category.find_by(name: 'Transactional'), confidence: 0.95) | ||
DetectorCategory.create(detector: Detector.find_by(name: 'PMID'), category: Category.find_by(name: 'Transactional'), confidence: 0.95) | ||
DetectorCategory.create(detector: Detector.find_by(name: 'Journal'), category: Category.find_by(name: 'Transactional'), confidence: 0.5) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateDetectors < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :detectors do |t| | ||
t.string :name | ||
|
||
t.timestamps | ||
end | ||
add_index :detectors, :name, unique: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateDetectorCategories < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :detector_categories do |t| | ||
t.belongs_to :detector, null: false, foreign_key: true | ||
t.belongs_to :category, null: false, foreign_key: true | ||
t.float :confidence | ||
|
||
t.timestamps | ||
end | ||
add_index :detector_categories, [:detector_id, :category_id] | ||
add_index :detector_categories, [:category_id, :detector_id] | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters