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

Added Training Codes to be stored, bugfixes #679

Merged

Conversation

horcsinbalint
Copy link
Member

Description

Added Training Codes to study lines and fixed bugs.

Related Issue

Closes #529.

Changes

  • Added Training Codes to study lines.
  • Bugfixes:
    • WorkshopBalances are now only recalculated when the Gazdasági Alelnök initiates this change (it should not be triggered automatically).
    • Decreased the time the current semester is cached to 10 seconds as having cache made debugging extremely difficult. With 10 seconds, the caching has its probable positive effects but it causes interference harder.

Added Training Codes to study lines.
Bugfixes:

- WorkshopBalances are now only recalculated when the Gazdasági Alelnök
  initiates this change (it should not be triggered automatically).

- Decreased the time the current semester is cached to 10 seconds as
  having cache made debugging extremely difficult. With 10 seconds, the
  caching has its probable positive effects but it causes interference
  harder.
@horcsinbalint horcsinbalint requested a review from a team as a code owner January 6, 2025 18:34
Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a comprehensive enhancement to handle training codes for study lines across the application. This involves adding a new training_code field to the StudyLine model, updating database migrations, modifying validation rules, and adjusting user interfaces to support and display this additional educational information. The changes span multiple components, including models, controllers, views, and language files, ensuring a cohesive implementation of training code tracking.

Changes

File Change Summary
Makefile Added clear_cache target for Laravel cache management
app/Http/Controllers/Secretariat/UserController.php Added validation for training_code in study lines
app/Models/Semester.php Modified cache expiration to 10 seconds
app/Models/StudyLine.php Added training_code property and updated getNameWithYear() method
database/migrations/... Created migration to add training_code column to study_lines table
resources/lang/en/user.php, resources/lang/hu/user.php Added localisation for study_line_training_code
resources/views/... Updated form layouts to include training code input

Assessment against linked issues

Objective Addressed Explanation
Store training codes
Collect during application
Display on user profile
Provide localised guidance No explicit guidance text added

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 854f3e1 and 7feed7f.

📒 Files selected for processing (1)
  • tests/Feature/ApplicationTest.php (1 hunks)
🔇 Additional comments (1)
tests/Feature/ApplicationTest.php (1)

238-239: ⚠️ Potential issue

Address the reported test failure and enhance test data management.

The test is failing with a 500 error due to an "Undefined array key 'training_code'" error in UserController.php. This suggests that while the test has been updated to include the training code, the controller might not be properly handling this new field.

Let's verify the controller implementation with this script:

Additionally, consider these improvements:

  1. Use a constant or test helper for the training code format instead of hardcoding "123456"
  2. Add test cases for invalid training codes
  3. Consider adding assertions to verify that the training code was properly saved

Here's a suggested enhancement to improve test data management:

-                "training_code" => "123456"]],
+                "training_code" => self::MOCK_TRAINING_CODE]],

And add at the top of the class:

private const MOCK_TRAINING_CODE = "123456";

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (6)
database/migrations/2025_01_06_183456_add_training_code_to_study_lines.php (1)

15-15: Consider preparing for future non-nullable requirements.
This column is currently marked as nullable, yet the comment hints at making it mandatory in due course. To avoid data inconsistency, you might wish to employ a two-phase migration: firstly introducing the column as nullable, then updating existing records, and finally converting it to NOT NULL in a later migration.

database/factories/StudyLineFactory.php (1)

26-26: Promote consistent data generation.
This usage of Faker is beneficial for testing. If reliability is paramount, you might consider generating always non-null codes in certain test scenarios. This will ensure coverage for real-world usage where a code may eventually be mandatory.

resources/views/user/study-line-selector.blade.php (2)

4-4: Check UX implications of narrower fields.
The reduction from xl=6 to xl=4 could hamper readability if lengthy study line names are entered. Please ensure that this smaller field size remains user-friendly.


20-20: Minor field size adjustment.
Decreasing the minor field to xl=3 from xl=4 is a subtle layout change. Kindly confirm it still presents all relevant data clearly.

app/Models/StudyLine.php (1)

114-116: Graceful concatenation of the training code.
Appending the training code here is a neat extension of the existing getNameWithYear() logic. Be mindful of potential whitespace or punctuation nuances in future expansions.

app/Http/Controllers/Secretariat/UserController.php (1)

172-172: Prudent validation rule added.
Enforcing 'string|max:255' ensures that training codes remain within feasible limits. If the training code is optional, you might consider adding 'nullable' for completeness.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f607fe5 and 76a30b9.

📒 Files selected for processing (12)
  • Makefile (1 hunks)
  • app/Http/Controllers/Secretariat/UserController.php (2 hunks)
  • app/Http/Controllers/StudentsCouncil/EconomicController.php (0 hunks)
  • app/Models/Semester.php (1 hunks)
  • app/Models/StudyLine.php (3 hunks)
  • app/Models/User.php (0 hunks)
  • database/factories/StudyLineFactory.php (1 hunks)
  • database/migrations/2025_01_06_183456_add_training_code_to_study_lines.php (1 hunks)
  • resources/lang/en/user.php (1 hunks)
  • resources/lang/hu/user.php (1 hunks)
  • resources/views/auth/application/application.blade.php (1 hunks)
  • resources/views/user/study-line-selector.blade.php (2 hunks)
💤 Files with no reviewable changes (2)
  • app/Http/Controllers/StudentsCouncil/EconomicController.php
  • app/Models/User.php
🔇 Additional comments (10)
database/migrations/2025_01_06_183456_add_training_code_to_study_lines.php (1)

25-25: Confirm necessity of rollback data.
In the down method, dropping the column is perfectly acceptable. Kindly ensure that any critical information stored in training_code has been addressed or migrated elsewhere beforehand, if needed.

resources/views/user/study-line-selector.blade.php (1)

14-18: Excellent addition of the training code field.
Adding this new input aligns with your backend changes, ensuring the system now collects and manages the training_code as intended.

resources/lang/hu/user.php (1)

79-79: Appreciation for localisation completeness.
Introducing 'study_line_training_code' => 'Képzési kód' is an appropriate step towards a fully localised user experience. Thank you for maintaining consistency in translations.

resources/lang/en/user.php (1)

79-79: Splendid addition for consistency.
This new key harmonises impeccably with the system's structure, enabling future expansions involving training codes.

app/Models/StudyLine.php (2)

18-18: Doc block appears accurate.
This newly introduced @property string $training_code is well-defined, helping maintain clarity in type-hinting and code completion.


51-51: Proper mass assignment inclusion.
Adding 'training_code' to $fillable is essential for seamless creation and updating of study lines.

app/Models/Semester.php (1)

280-280: Caching set to 10 seconds.
A cache duration of 10 seconds may significantly increase cache misses, though ideal for debugging. Do ensure this short interval does not hinder production performance.

app/Http/Controllers/Secretariat/UserController.php (1)

226-226: Seamless integration of the training code.
Including 'training_code' in the study line creation fosters consistent data storage and retrieval.

resources/views/auth/application/application.blade.php (1)

167-167: Including year in study line display is splendid
It is quite a marvellous idea to include the year in the study line display. Kindly ensure that if the training_code is also appended within the getNameWithYear() method, it is being showcased correctly when present.

Makefile (1)

15-20: Delightful new target for clearing caches
This splendid clear_cache target succinctly clears various Laravel caches, which should greatly facilitate debugging. You may wish to add a brief comment in the Makefile or README clarifying that this command is best utilised in development or while troubleshooting, as frequent cache clearing can degrade performance in a production setting.

@horcsinbalint
Copy link
Member Author

The Szakmai Alelnök approved the changes in the perspective of a user

@BertalanD
Copy link
Member

Please fix the unit tests:

1) Tests\Feature\ApplicationTest::test_submit
Expected response status code [302] but received 500.
Failed asserting that 500 is identical to 302.

The following exception occurred during the last request:

ErrorException: Undefined array key "training_code" in /__w/mars/mars/app/Http/Controllers/Secretariat/UserController.php:[22](https://github.com/EotvosCollegium/mars/actions/runs/12640423722/job/35220811301?pr=679#step:8:23)6

@horcsinbalint horcsinbalint merged commit 92d587b into EotvosCollegium:development Jan 8, 2025
3 of 4 checks passed
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.

Store training codes
2 participants