Skip to content

Comments

Fix/save code description and audit order#201

Merged
alessandrobelli merged 9 commits intomainfrom
fix/save-code-description-and-audit-order
Oct 14, 2025
Merged

Fix/save code description and audit order#201
alessandrobelli merged 9 commits intomainfrom
fix/save-code-description-and-audit-order

Conversation

@alessandrobelli
Copy link
Contributor

This pull request adds support for storing and validating a code's description when creating new codes, improves audit timestamp handling for more reliable sorting and filtering, and introduces new feature tests for code creation. The main changes are grouped below:

Code Creation and Validation

  • Added support for storing a description when creating a new code in CodingController.php, and updated validation rules to make description an optional string up to 500 characters in StoreCodeRequest.php. [1] [2]
  • Introduced feature tests for creating codes with all attributes (including description) and without description, ensuring correct database behavior in CodeControllerTest.php.

Audit Logging Improvements

  • Audit transformation now includes a created_at_timestamp field, and audit sorting is updated to use this timestamp for more reliable ordering in both AuditService.php and User.php. [1] [2] [3]
  • Date range filtering for audits now uses the new timestamp field for improved accuracy in AuditService.php.

Documentation and Test Coverage

  • Updated docs/CURRENT-TESTS.md to reflect new test cases for code creation with and without description, and for private codebook access. [1] [2] [3]

Solve #199

Alessandro Belli added 2 commits October 13, 2025 11:18
Code creation now accepts an optional description field, validated as nullable and up to 500 characters. Audit sorting and filtering now use a timestamp for created_at, improving date handling. Tests added for creating codes with and without descriptions.
Appends ->values() after sorting audit collections by 'created_at_timestamp' in User and AuditService classes to reset indexes. This improves consistency when returning sorted collections.
@alessandrobelli alessandrobelli self-assigned this Oct 13, 2025
@alessandrobelli alessandrobelli added the bug Something isn't working label Oct 13, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for storing and validating code descriptions during creation, improves audit timestamp handling for more reliable sorting and filtering, and introduces comprehensive feature tests for code creation scenarios.

  • Added optional description field support to code creation with proper validation (up to 500 characters)
  • Enhanced audit system with timestamp-based sorting and filtering for improved reliability
  • Added comprehensive test coverage for code creation with and without descriptions

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
web/tests/Feature/CodeControllerTest.php Added feature tests for code creation with and without description fields
web/app/Services/AuditService.php Enhanced audit transformation with timestamp field and improved sorting/filtering
web/app/Models/User.php Updated audit sorting to use timestamp field instead of date string
web/app/Http/Requests/StoreCodeRequest.php Added validation rule for optional description field
web/app/Http/Controllers/CodingController.php Added description field assignment during code creation
docs/CURRENT-TESTS.md Updated test documentation with new test cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Alessandro Belli added 6 commits October 13, 2025 11:48
Refines conditional rendering to show color backgrounds only for 'Code' model and 'color' key. Adds handling for 'source.locked' audit events to display locked model information. Enhances clarity and accuracy of audit event presentation.
Added 'modifying_user_id' to the list of attributes excluded from auditing in Project model, but included it in audit transformation for both User and AuditService. Updated Audit.vue to display the code name when relevant for audit entries. This improves audit traceability and UI clarity for code-related changes.
Corrects conditional rendering logic for 'created' and 'modified' audit events when the model is 'Codebook' and the key is 'description' with a null value. Ensures proper display of audit messages in these cases.
Eliminates the 'modifying_user_id' field from project audit exclusion and audit transformation logic in Project, User, and AuditService classes. Also cleans up related conditional display logic in Audit.vue to simplify audit event rendering.
kadewe
kadewe previously approved these changes Oct 13, 2025
Copy link
Contributor

@kadewe kadewe left a comment

Choose a reason for hiding this comment

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

OK, wow, so we just forgot to save the description 😬?

Please have a look at my max:500 char string length comment, I think this is to short. If the database supports it, make it longer to 1000 char.

The maximum allowed length for the 'description' field in StoreCodeRequest has been increased from 500 to 5000 characters to support longer input.
Copy link

@hohse hohse left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@alessandrobelli alessandrobelli merged commit 8516a31 into main Oct 14, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants