Skip to content

Conversation

@SeojinSeojin
Copy link
Contributor

No description provided.

@github-actions
Copy link

github-actions bot commented Nov 25, 2025

2 Warnings
⚠️ Pull request is too big (more than 500 LoC).
⚠️ RSpec tests seem shallow (single it blocks or no context). Consider improving test structure.

Generated by 🚫 Danger

@github-actions
Copy link

🚨 RSpec Tests Report

Failing Model Test Cases:
rspec ./spec/models/due_date_spec.rb:13 # DueDate.fetch_due_dates fetches all the due_dates from a due_date's parent
rspec ./spec/models/due_date_spec.rb:33 # DueDate.sort_due_dates sorts a list of due dates from earliest to latest
rspec ./spec/models/due_date_spec.rb:52 # DueDate.any_future_due_dates? returns true when a future due date exists
rspec ./spec/models/due_date_spec.rb:63 # DueDate.any_future_due_dates? returns true when a no future due dates exist
rspec ./spec/models/due_date_spec.rb:78 # DueDate.set returns true when a future due date exists
rspec ./spec/models/due_date_spec.rb:96 # DueDate.copy copies the due dates from one assignment to another
rspec ./spec/models/due_date_spec.rb:135 # DueDate.next_due_date when parent_type is Assignment returns the next upcoming due date
rspec ./spec/models/due_date_spec.rb:168 # DueDate.next_due_date when parent_type is SignUpTopic calls TopicDueDate.next_due_date
rspec ./spec/models/due_date_spec.rb:174 # DueDate.next_due_date when parent_type is SignUpTopic returns the next upcoming due date for topics
rspec ./spec/models/due_date_spec.rb:179 # DueDate.next_due_date when parent_type is SignUpTopic returns the next assignment due date when topic has no upcoming due dates
rspec ./spec/models/due_date_spec.rb:190 # DueDate validation is invalid without a parent
rspec ./spec/models/due_date_spec.rb:196 # DueDate validation is invalid without a due_at
rspec ./spec/models/due_date_spec.rb:202 # DueDate validation is valid with required fields

Copy link
Member

@efg efg left a comment

Choose a reason for hiding this comment

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

Please try to reduce the size of your code by 90%+. It would be much clearer if it was shorter and easy to grasp by just reading through it once.

activity_permissible?(:drop_topic)
end

# Check activity permissions for a specific deadline type
Copy link
Member

Choose a reason for hiding this comment

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

This method should be removed completely. The deadline type has nothing to do with whether an activity is permissible. Whether an activity is permissible is entirely determined by the submission_allowed_id, review_allowed_id, etc. Leaving this method in the code will simply confuse anyone who needs to maintain or extend this code.

current_deadline_for(action)
end

# Check if a specific action is currently allowed based on deadlines
Copy link
Member

Choose a reason for hiding this comment

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

This code seems repetitious. I wonder if there is a good way to simplify it, perhaps using metaprogramming. Be careful; ask an LLM.

end
end

# Get all currently allowed actions
Copy link
Member

Choose a reason for hiding this comment

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

I see no reason that this method would ever be needed. The currently allowed actions are determined by the ..._allowed fields in the next due date. Collecting them together serves no purpose that I can imagine.

actions
end

# Check if any actions are currently allowed
Copy link
Member

Choose a reason for hiding this comment

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

Again, I can't imagine how this method would ever be useful. If an assignment is Finished (i.e., all of its due_dates are in the past), no actions are currently allowed. If the available_to_students bit is set and it has future due dates, some action is always allowed. I can think of no counterexamples in the history of Expertiza. Please remove it.

allowed_actions.any?
end

# Get permission summary for all actions
Copy link
Member

Choose a reason for hiding this comment

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

Again, I can think of no use for this method. It should be removed.

scope :with_penalty, -> { where(name: 'Late') }
scope :without_penalty, -> { where(name: 'OK') }

# Class methods for finding deadline rights
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure whether the following methods would be needed. Please try to think of where they would be called. It's plausible that they would be helpful, but unless we can see a use, I think it's better not to include them.

end
end

# Comparison methods
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure this would never be used.

permission_level <=> other.permission_level
end

# Method to seed the deadline rights (for use in migrations/seeds)
Copy link
Member

Choose a reason for hiding this comment

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

It seems to me that seeding code should not be in classes within the application. Probably more appropriate for test classes. Ask an LLM.

valid_right_names.include?(name.to_s)
end

# Statistics methods
Copy link
Member

Choose a reason for hiding this comment

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

YAGNI, I think.

scope :quiz_types, -> { where(name: ['quiz']) }
scope :administrative_types, -> { where(name: ['drop_topic', 'signup', 'team_formation']) }

# Class methods for finding deadline types
Copy link
Member

Choose a reason for hiding this comment

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

How would you envision these methods being used? If it's not clear, they should not be included.

@github-actions
Copy link

🚨 RSpec Tests Report

All tests passed.

1 similar comment
@github-actions
Copy link

🚨 RSpec Tests Report

All tests passed.

# Shift deadlines of a specific type
def shift_deadlines_of_type(deadline_type_name, time_delta)
# Shift deadlines of a specific type by a time interval
def shift_deadlines_of_type(deadline_type_name, time_interval)
Copy link
Member

Choose a reason for hiding this comment

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

I would only expect the time interval to be expressed in DAYS. I think that using "days" as identifier names and in the calculation would improve the readability of this method.

end

# Check if deadlines are properly ordered (submission before review, etc.)
# Check if deadlines are in proper chronological order
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this method is useful. You can put them in order with a single statement. If you wanted them to be in order, you'd just sort them. Please remove this method.

activities
end

# Check if this deadline is currently active (allows some action)
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any need for this method. All deadlines allow for something to be done, in my experience. I also don't think it's necessary to check whether ANYTHING can be done ... just whether a specific action can be performed.

teammate_review: permission_status_for(:teammate_review),
active: active?,
closed: closed?
active: active?
Copy link
Member

Choose a reason for hiding this comment

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

Please remove. "active" is not helpful.

.first
def next_due_date(topic_id = nil)
if topic_id && has_topic_specific_deadlines?
topic_deadline = due_dates.where(parent_id: topic_id, parent_type: 'SignUpTopic')
Copy link
Member

Choose a reason for hiding this comment

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

"SignupTopics" (old repo) will be "ProjectTopics" in the new system.

# Instance methods for parent objects (Assignment, SignUpTopic)
# These methods should be included in Assignment and SignUpTopic models

# Get next due date for this parent
Copy link
Member

Choose a reason for hiding this comment

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

I assume that "topic_id" here means the primary key of the topic in the topics table.
It is not guaranteed that all topics will have user-assigned numbers like "E2566".

end

# Get all deadlines affecting a specific topic
# Get all deadlines for a topic (topic-specific + assignment fallback)
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any need to collect all deadlines for a topic. Another case of YAGNI.


# Check if assignment has topic-specific overrides
def has_topic_deadline_overrides?
# Check if assignment has topic-specific deadlines
Copy link
Member

Choose a reason for hiding this comment

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

This check should really be made by checking whether the assignment is a staggered-deadline assignment. This is determined by the staggered_deadline field in the Assignment object.

@github-actions
Copy link

🚨 RSpec Tests Report

All tests passed.

@github-actions
Copy link

🚨 RSpec Tests Report

All tests passed.

1 similar comment
@github-actions
Copy link

🚨 RSpec Tests Report

All tests passed.

Notes: talk about the participant parameter and anything else that is required before submission.
@github-actions
Copy link

🚨 RSpec Tests Report

Failing Model Test Cases:
rspec ./spec/models/due_date_spec.rb:13 # DueDate.fetch_due_dates fetches all the due_dates from a due_date's parent
rspec ./spec/models/due_date_spec.rb:33 # DueDate.sort_due_dates sorts a list of due dates from earliest to latest
rspec ./spec/models/due_date_spec.rb:52 # DueDate.any_future_due_dates? returns true when a future due date exists
rspec ./spec/models/due_date_spec.rb:63 # DueDate.any_future_due_dates? returns true when a no future due dates exist
rspec ./spec/models/due_date_spec.rb:78 # DueDate.set returns true when a future due date exists
rspec ./spec/models/due_date_spec.rb:96 # DueDate.copy copies the due dates from one assignment to another
rspec ./spec/models/due_date_spec.rb:135 # DueDate.next_due_date when parent_type is Assignment returns the next upcoming due date
rspec ./spec/models/due_date_spec.rb:168 # DueDate.next_due_date when parent_type is SignUpTopic calls TopicDueDate.next_due_date
rspec ./spec/models/due_date_spec.rb:174 # DueDate.next_due_date when parent_type is SignUpTopic returns the next upcoming due date for topics
rspec ./spec/models/due_date_spec.rb:179 # DueDate.next_due_date when parent_type is SignUpTopic returns the next assignment due date when topic has no upcoming due dates
rspec ./spec/models/due_date_spec.rb:190 # DueDate validation is invalid without a parent
rspec ./spec/models/due_date_spec.rb:196 # DueDate validation is invalid without a due_at
rspec ./spec/models/due_date_spec.rb:202 # DueDate validation is valid with required fields

@github-actions
Copy link

🚨 RSpec Tests Report

Failing Model Test Cases:
rspec ./spec/models/due_date_spec.rb:13 # DueDate.fetch_due_dates fetches all the due_dates from a due_date's parent
rspec ./spec/models/due_date_spec.rb:33 # DueDate.sort_due_dates sorts a list of due dates from earliest to latest
rspec ./spec/models/due_date_spec.rb:52 # DueDate.any_future_due_dates? returns true when a future due date exists
rspec ./spec/models/due_date_spec.rb:63 # DueDate.any_future_due_dates? returns true when a no future due dates exist
rspec ./spec/models/due_date_spec.rb:78 # DueDate.set returns true when a future due date exists
rspec ./spec/models/due_date_spec.rb:96 # DueDate.copy copies the due dates from one assignment to another
rspec ./spec/models/due_date_spec.rb:135 # DueDate.next_due_date when parent_type is Assignment returns the next upcoming due date
rspec ./spec/models/due_date_spec.rb:168 # DueDate.next_due_date when parent_type is SignUpTopic calls TopicDueDate.next_due_date
rspec ./spec/models/due_date_spec.rb:174 # DueDate.next_due_date when parent_type is SignUpTopic returns the next upcoming due date for topics
rspec ./spec/models/due_date_spec.rb:179 # DueDate.next_due_date when parent_type is SignUpTopic returns the next assignment due date when topic has no upcoming due dates
rspec ./spec/models/due_date_spec.rb:190 # DueDate validation is invalid without a parent
rspec ./spec/models/due_date_spec.rb:196 # DueDate validation is invalid without a due_at
rspec ./spec/models/due_date_spec.rb:202 # DueDate validation is valid with required fields

Failing Controller Test Cases:
rspec ./spec/requests/api/v1/assignment_controller_spec.rb:243 # Assignments API /assignments/{assignment_id}/copy_assignment post assignment copied successfully returns a 200 response

Refactored due date implementation.

- Remove redundant next_due_date method from TopicDueDate class
- Clean up DueDate class by removing duplicate class method
- Improve next_due_date method in DueDateActions with better documentation
- Add missing due_dates association to Assignment model (was incorrectly documented as provided by mixin)
- Enhance DueDatePermissions documentation explaining participant permission requirements
- Simplify TopicDueDate to proper single table inheritance subclass
@github-actions
Copy link

🚨 RSpec Tests Report

Failing Model Test Cases:
rspec ./spec/models/due_date_spec.rb:13 # DueDate.fetch_due_dates fetches all the due_dates from a due_date's parent
rspec ./spec/models/due_date_spec.rb:33 # DueDate.sort_due_dates sorts a list of due dates from earliest to latest
rspec ./spec/models/due_date_spec.rb:52 # DueDate.any_future_due_dates? returns true when a future due date exists
rspec ./spec/models/due_date_spec.rb:63 # DueDate.any_future_due_dates? returns true when a no future due dates exist
rspec ./spec/models/due_date_spec.rb:78 # DueDate.set returns true when a future due date exists
rspec ./spec/models/due_date_spec.rb:96 # DueDate.copy copies the due dates from one assignment to another
rspec ./spec/models/due_date_spec.rb:135 # DueDate.next_due_date when parent_type is Assignment returns the next upcoming due date
rspec ./spec/models/due_date_spec.rb:168 # DueDate.next_due_date when parent_type is SignUpTopic calls TopicDueDate.next_due_date
rspec ./spec/models/due_date_spec.rb:174 # DueDate.next_due_date when parent_type is SignUpTopic returns the next upcoming due date for topics
rspec ./spec/models/due_date_spec.rb:179 # DueDate.next_due_date when parent_type is SignUpTopic returns the next assignment due date when topic has no upcoming due dates
rspec ./spec/models/due_date_spec.rb:190 # DueDate validation is invalid without a parent
rspec ./spec/models/due_date_spec.rb:196 # DueDate validation is invalid without a due_at
rspec ./spec/models/due_date_spec.rb:202 # DueDate validation is valid with required fields

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

🚨 RSpec Tests Report

All tests passed.

end

# Get the next due date for this parent
# Get the next due date for this assignment
Copy link
Member

Choose a reason for hiding this comment

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

Code is just fine. I would suggest appending lines 66 & 67 to line 65 for better readability. I also think you may have gone overboard on the comments; perhaps you could ask an LLM how to comment the method just as clearly but more concisely.


where(parent_id: parent_id).upcoming.first
end
# This method is no longer needed as the functionality has been moved
Copy link
Member

Choose a reason for hiding this comment

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

Agreed, but the method should be removed entirely from the code (comments and all).

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

🚨 RSpec Tests Report

All tests passed.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

🚨 RSpec Tests Report

All tests passed.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

🚨 RSpec Tests Report

Failing Model Test Cases:
rspec ./spec/models/assignment_spec.rb:183 # Assignment#deadlines_properly_ordered? returns false when ordering wrong

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

🚨 RSpec Tests Report

All tests passed.


# Get the current stage name for display purposes
def current_stage
deadline = next_due_date
Copy link
Member

Choose a reason for hiding this comment

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

deadline --> upcoming_due_date

…e_actions for more readability on line 15 and removed cannot_delete_if_has_due_dates as it would only be triggered via admin view which wouldn't exist anymore.
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

🚨 RSpec Tests Report

All tests passed.


create_table "deadline_types", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name", null: false
t.text "description", null: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not need description text field. remove it


create_table "deadline_rights", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name", null: false
t.text "description", null: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not need description text field. remove it

t.integer "review_of_review_allowed_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["deadline_type_id"], name: "fk_rails_ee95f82c0c"
Copy link
Collaborator

Choose a reason for hiding this comment

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

get rid of description_url, flag, deadline_name

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