-
Notifications
You must be signed in to change notification settings - Fork 3
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
Populate user subjects based on documents #634
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.
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?
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.
Muy de acuerdo
Co-authored-by: Renzo Minelli <[email protected]>
@@ -11,6 +11,12 @@ def add(approvable) | |||
end | |||
end | |||
|
|||
def force_add_subject(subject) |
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.
Capaz deberias agregar un test de modelo para esto
lib/transcript/academic_entry.rb
Outdated
grade != '***' | ||
end | ||
|
||
def save_to_user(user) |
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.
Para mi deberias poner un test para este metodo
@@ -30,6 +30,8 @@ | |||
|
|||
resources :current_optional_subjects, only: :index | |||
|
|||
resources :transcripts, only: [:new, :create] |
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.
debería ser un resource
singular esto?
require 'pdf-reader' | ||
require_relative 'academic_entry' |
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.
son necesarios estos require
?
@@ -0,0 +1,39 @@ | |||
module Transcript |
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 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) |
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.
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? |
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.
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? } |
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.
capaz queda mejor subject_match.reject(&:inactive?)
?
ids << subject.exam.id if subject.exam && !ids.include?(subject.exam.id) | ||
ids << subject.course.id if subject.course && !ids.include?(subject.course.id) |
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.
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 |
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.
todos estos atributos tienen que ser públicos?
o cuáles se usan desde afuera?
@number_of_failures = number_of_failures | ||
@date_of_completion = date_of_completion |
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.
se usan para algo estos atributos?
<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> |
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.
para mi esto debería ser otra página, o mostrar como un flash message
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.
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.
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.
Agregué un ticket para eso! https://github.com/orgs/cedarcode/projects/3?pane=issue&itemId=109539243
https://github.com/user-attachments/assets/da254887-94c4-45b2-8672-0a44a5f3c73d
