Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

frankete333
Copy link
Member

Screen.Recording.2025-01-21.at.9.56.23.PM.mov

end

def index
redirect_to new_academic_history_path
Copy link
Collaborator

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?

@frankete333 frankete333 marked this pull request as ready for review February 13, 2025 23:18
class PdfProcessor
include Enumerable

AcademicEntry = Struct.new(:name, :credits, :number_of_failures, :date_of_completion, :grade) do
Copy link
Collaborator

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]
Copy link
Collaborator

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?

Comment on lines +1 to +2
require 'pdf-reader'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require 'pdf-reader'

Comment on lines +4 to +6
def index
redirect_to new_academic_history_path
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def index
redirect_to new_academic_history_path
end

end

def create
file = params[:file]
Copy link
Collaborator

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'
Copy link
Collaborator

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|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Collaborator

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/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/\*{10}|\d\d\/\d\d\/\d\d\d\d/
/\*{10}|\d{2}\/\d{2}\/\d{4}/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants