Skip to content

Populate user subjects based on documents #634

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

Merged
merged 34 commits into from
May 1, 2025

Conversation

frankete333
Copy link
Member

@frankete333 frankete333 commented Jan 22, 2025

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.

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Muy de acuerdo

@@ -11,6 +11,12 @@ def add(approvable)
end
end

def force_add_subject(subject)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capaz deberias agregar un test de modelo para esto

grade != '***'
end

def save_to_user(user)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Para mi deberias poner un test para este metodo

@frankete333 frankete333 merged commit de2dda7 into master May 1, 2025
5 checks passed
@frankete333 frankete333 deleted the populate-user-subjects-based-on-documents branch May 1, 2025 03:06
@@ -30,6 +30,8 @@

resources :current_optional_subjects, only: :index

resources :transcripts, only: [:new, :create]
Copy link
Collaborator

Choose a reason for hiding this comment

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

debería ser un resource singular esto?

Comment on lines +1 to +2
require 'pdf-reader'
require_relative 'academic_entry'
Copy link
Collaborator

Choose a reason for hiding this comment

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

son necesarios estos require?

@@ -0,0 +1,39 @@
module Transcript
Copy link
Collaborator

Choose a reason for hiding this comment

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

por qué ponerlo en lib y no en app/services o algo del estilo?

class AcademicEntry
attr_accessor :name, :credits, :number_of_failures, :date_of_completion, :grade

def initialize(name: nil, credits: nil, number_of_failures: nil, date_of_completion: nil, grade: nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

para mi habría que sacar los defaults, ya que siempre se le pasan todas las keys

def save_to_user(student)
subject = subject_from_name(name)

return false if subject.blank?
Copy link
Collaborator

Choose a reason for hiding this comment

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

return unless subject

siempre va a ser un subject o nil, no?


return subject_match.first if subject_match.length == 1

active_subjects = subject_match.select { |subject| !subject.inactive? }
Copy link
Collaborator

Choose a reason for hiding this comment

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

capaz queda mejor subject_match.reject(&:inactive?)?

Comment on lines +15 to +16
ids << subject.exam.id if subject.exam && !ids.include?(subject.exam.id)
ids << subject.course.id if subject.course && !ids.include?(subject.course.id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

if subject.exam && ids.exclude?(subject.exam.id)

@@ -0,0 +1,39 @@
module Transcript
class AcademicEntry
attr_accessor :name, :credits, :number_of_failures, :date_of_completion, :grade
Copy link
Collaborator

Choose a reason for hiding this comment

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

todos estos atributos tienen que ser públicos?
o cuáles se usan desde afuera?

Comment on lines +8 to +9
@number_of_failures = number_of_failures
@date_of_completion = date_of_completion
Copy link
Collaborator

Choose a reason for hiding this comment

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

se usan para algo estos atributos?

Comment on lines +21 to +34
<div>
<% if @successful_subjects.present? %>
<p class="text-green-600 mb-2"><%= @successful_subjects.length %> Materias marcadas correctamente</p>
<% @successful_subjects.each do |subject| %>
<p class="text-gray-700"><%= subject.code %> - <%= subject.name %></p>
<% end %>
<% end %>
<% if @failed_entries.present? %>
<p class="text-red-600 my-2"><%= @failed_entries.length %> Materias no encontradas</p>
<% @failed_entries.each do |entry| %>
<p class="text-gray-700"><%= entry.name %></p>
<% end %>
<% end %>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

para mi esto debería ser otra página, o mostrar como un flash message

Copy link
Collaborator

Choose a reason for hiding this comment

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

Para mi está bien como primera versión, pero yo intentaría ahora pensar en cómo mejorarlo, sí. Yo había pensado en un modal o algo así también, aunque una página aparte no me parece mal tampoco.

Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

4 participants