-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Populate user subjects based on documents #634
base: master
Are you sure you want to change the base?
Conversation
end | ||
|
||
def index | ||
redirect_to new_academic_history_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Por que definis el index si el boton en el menu lleva al new? Se podria sacar?
class PdfProcessor | ||
include Enumerable | ||
|
||
AcademicEntry = Struct.new(:name, :credits, :number_of_failures, :date_of_completion, :grade) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creo que deberias mover esto a una clase AcademicHistory::AcademicEntry
luego en esa clase podes definir un metodo como save_academic_entry_to_user(user)
y moves el codigo que dejaste en el controller para ahi.
Además, asi podemos hacer test sobre esa clase.
@@ -30,6 +30,8 @@ | |||
|
|||
resources :current_optional_subjects, only: :index | |||
|
|||
resources :academic_histories, only: [:new, :create, :index] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
puede ser que se le llame "transcript" en inglés?
require 'pdf-reader' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require 'pdf-reader' |
def index | ||
redirect_to new_academic_history_path | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def index | |
redirect_to new_academic_history_path | |
end |
end | ||
|
||
def create | ||
file = params[:file] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yo usaría params.require(:file)
, y en el html ponerle required: true
y me parece que después no sería necesario chequear que file
exista
@failed_entries = [] | ||
@successful_entries = [] | ||
|
||
if file && file.content_type == 'application/pdf' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
es necesario el file.content_type == 'application/pdf'
dado que el html ya tiene accept: "application/pdf"
?
si alguien manda un archivo que no es un pdf va a fallar de todas formas?
|
||
def each | ||
reader.pages.each do |page| | ||
page.text.split("\n").each do |line| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
page.text.split("\n").each do |line| | |
page.text.each_line do |line| |
no es exactamente lo mismo porque cada línea va a terminar con /n
, pero creo que en este caso te sirve igual
require 'pdf-reader' | ||
|
||
module AcademicHistory | ||
class PdfProcessor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opiniones sobre renombrar esta clase a PdfParser
y hacer otro PdfProcessor
que llame al parser y después haga lo que está haciendo el controlelr de iterar y crear las materias aprobadas?
|
||
# The date can be either a date in the format DD/MM/YYYY or ********** | ||
def date_regex | ||
/\*{10}|\d\d\/\d\d\/\d\d\d\d/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/\*{10}|\d\d\/\d\d\/\d\d\d\d/ | |
/\*{10}|\d{2}\/\d{2}\/\d{4}/ |
Screen.Recording.2025-01-21.at.9.56.23.PM.mov