This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add points and extended subjects data from warsaw (#50)
* add data fron warsaw in json * add new models * remove all references to previous model names * remove class profiles from institutions * add creating subjects and mapping gdynia data to subjects * saving work, add warsaw data processing service object * process data from warsaw * save work on subject filtering * debugging saving work * almost finished just cleanup left * update docs * remove bug * refactor index controller * remove refactoring leftovers * remove error * test /subjects endpoint * rewrite and test CreateSubjectsService * use map inside CreaseSubjectService instead of each * refactor loading raw school data in warsaw job * refactor warsaw processing data service * add comments in warsaw data service * refactor creating subject set requirements info to another service and test it * create SubjectSetRequirementInfo factory * remove unnecessary specs Co-authored-by: Pawel Biegun <[email protected]>
- Loading branch information
1 parent
907f173
commit 78b173b
Showing
28 changed files
with
7,206 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class SubjectsController < ApplicationController | ||
def index | ||
@subjects = Subject.all | ||
render status: '200', json: { | ||
subjects: @subjects | ||
} | ||
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 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateSubjectsJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform() | ||
CreateSubjectsService.new.call | ||
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 @@ | ||
# frozen_string_literal: true | ||
|
||
class ProcessWarsawDataJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform() | ||
ProcessWarsawDataService.new.call | ||
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
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Subject < ApplicationRecord | ||
has_and_belongs_to_many :subject_sets | ||
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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class SubjectSet < ApplicationRecord | ||
has_one :subject_set_requirements_info, dependent: :destroy | ||
belongs_to :institution | ||
has_and_belongs_to_many :subjects | ||
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,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class SubjectSetRequirementsInfo < ApplicationRecord | ||
belongs_to :subject_set | ||
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,40 @@ | ||
class CreateSubjectsService < ApplicationService | ||
#This service creates all the subjects that can be included in subject sets. | ||
def call | ||
#These are the only extended subject fields can be used in subject_sets | ||
#If there are new subjects that are not in this list it should be updated | ||
subject_names = [ | ||
"Polski", | ||
"Matematyka", | ||
"Fizyka", | ||
"Chemia", | ||
"Geografia", | ||
"Historia", | ||
"WOS", | ||
"Informatyka", | ||
"Biologia", | ||
"Sztuka", | ||
"Dziennikarstwo", | ||
"Prawo", | ||
"Medycyna", | ||
"Nauki ścisłe", | ||
"Ekonomia", | ||
"Zarządzanie", | ||
"Angielski", | ||
"Hiszpański", | ||
"Niemiecki", | ||
"Historia Sztuki", | ||
"Włoski", | ||
"Rosyjski", | ||
"Francuski", | ||
"Gotowanie", | ||
"Muzyka", | ||
"Technik", | ||
"Antyk", | ||
"Fotografia", | ||
"Złotnik" | ||
] | ||
|
||
subject_names.map { |name| Subject.create(name: name) } | ||
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
Oops, something went wrong.