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

Yearly report module with admin interface #711

Merged
merged 90 commits into from
Jan 2, 2025
Merged

Conversation

jhagberg
Copy link
Collaborator

Yearly Report Management System Enhancement

Overview

This pull request introduces a comprehensive set of features for managing and viewing yearly reports within the application, enhancing both the frontend user interface and backend API functionality.

Frontend Changes

New Components

  • YearlyReportViewer

    • Displays yearly reports for specific rounds
    • Includes table view of report data
    • Implements export functionality
    • Adds genebank selection capability
  • Report Management Components

    • YearlyReportRounds: Manages yearly report rounds (create, update, delete)
    • YearlyReportMultiStepForm: Multi-step form for report submission
    • YearlyReportStep: Handles report data display and updates
    • YearlyReportForm: Core form for yearly report data input
  • Supporting Components

    • BatchRabbitUpdateStep & BatchRabbitUpdateForm: Batch update functionality for rabbit data
    • HerdContactUpdateStep: Updated to include bank details
    • SelectGenebankStep: Genebank selection based on user permissions
    • SelectHerdStep: Herd selection with breeding information display

Technical Updates

  • Updated dependencies in package.json
    • Added formik and yup for form handling
    • Updated existing package versions
  • Modified tsconfig.json
    • Set allowJs and checkJs to false
    • Configured rootDir and outDir
    • Updated include/exclude paths

Backend Changes

API Endpoints

Added new endpoints for:

  • Yearly report round management (/api/manage/yearly_report_rounds)
  • Report viewing (/api/manage/yearly-reports/<round_id>/<genebank_id>)
  • CSV export functionality

Database Updates

  • Schema version updated to 14
  • New models:
    • YearlyReportRound
    • Enhanced Herd model with bank details
  • Removed GenebankReport model
  • Implemented migrations (v11 to v14)

Infrastructure

  • Updated Dockerfile to use node:18-slim
  • Enhanced data access layer in data_access.py
    • Added new role permissions
    • Implemented report management functions
    • Updated herd information handling

Testing

  • Added comprehensive test coverage for new components
  • Implemented validation testing for forms
  • Verified database migrations

Documentation

  • Updated API documentation
  • Added component documentation
  • Included migration guides

Breaking Changes

  • Database schema updates require migration
  • Updated node version requirements
  • Modified API response structures for yearly reports

feat(report): enhance YearlyReportForm with existing data merge and error handling

This update introduces the ability to prefill the YearlyReportForm with existing report data if available, enhancing user experience by reducing repetitive input. The change also includes improved error handling, displaying user-friendly messages when data fetching or submission encounters issues. Additionally, the commit refactors variable names for clarity and adjusts the form submission logic to include new publication settings based on user choices.
…parameter and update description handling; implement patch request in YearlyReportRounds component; add effect to check for active yearly report rounds in Navigation component
…ity logic based on active and manually activated rounds
…filter active report rounds in Navigation component
…on to allow all users; add error handling and logging
…mproved UI

Updated the SelectHerdStep component to include a breeding management dialog for adding and editing breedings. Introduced new state variables for managing selected breeding and dialog visibility. Enhanced the breeding table with sorting and filtering capabilities, including renumbering filtered breedings. Improved user guidance with updated instructions for reporting breedings. Additionally, added a new CSS class for consistent styling of yearly report cards. The BreedingForm component is now integrated for seamless breeding data management.
…ivacy handling

Deleted the unused test for the GenebankReport class in test_database.py. Updated the remove_fields_by_privacy function in database.py to improve handling of field deletions based on privacy levels, ensuring that only relevant fields are removed when access levels are checked. Additionally, enabled full diff for debugging in the test class to aid in future development.
Replaced 'docker-compose' with 'docker compose' in the create_packages.yml workflow file to align with the latest Docker CLI standards. This change ensures consistency in command usage and improves compatibility with newer Docker versions.
Updated the create_packages.yml workflow file to enhance the readability of the docker login command by splitting it across multiple lines. This change improves clarity and maintainability of the workflow configuration.
…e_yearly_report function

Enhanced the save_yearly_report function to include validation for herd existence and user permissions. Implemented error handling to return appropriate messages when the herd ID is invalid or the user lacks permission to modify the herd. This improves data integrity and user experience by ensuring only authorized modifications are allowed.
…unctionality

Refactored the lint.yml workflow to enhance readability by adding spaces in branch lists and updating comments for clarity. Changed the checkout action to use version 4 and updated the super-linter action to version 7. Added permissions for better control over GitHub Actions status checks. These changes improve the maintainability and functionality of the linting process.
…a_access.py

Refactored the data_access.py file to enhance code readability by applying consistent formatting, including line breaks and indentation adjustments. This change improves maintainability and clarity of the codebase, making it easier for developers to navigate and understand the logic within various functions.
…d improved Docker handling

Updated the create_packages.yml workflow to trigger builds based on specific file changes in the frontend, app, R API, and Docker configurations. Introduced a paths-filter action to optimize the build process by only building and pushing images that have changed. Improved Docker login and image handling steps for clarity and consistency with the latest Docker CLI standards. This refactor enhances the maintainability and efficiency of the CI/CD pipeline.
…s.yml

Updated the create_packages.yml workflow to change the Docker build target from 'frontend' to 'herdbook-frontend'. This adjustment ensures that the correct image is built based on the changes detected, improving the accuracy of the CI/CD pipeline.
…kages.yml

Updated the create_packages.yml workflow to sanitize branch names by replacing slashes with hyphens when tagging Docker images. This change ensures that branch names are compatible with Docker tagging conventions, improving the reliability of image builds and pushes in the CI/CD pipeline.
…ok.py

Refactored the herdbook.py file to enhance code readability by applying consistent formatting, including line breaks and indentation adjustments. This change improves maintainability and clarity of the codebase, making it easier for developers to navigate and understand the logic within various functions. Additionally, minor adjustments were made to logging messages for better clarity.
…formatting across multiple files

Refactored herdbook.py, data_access.py, and test_database.py to enhance code readability by applying consistent formatting, including line breaks and indentation adjustments. These changes improve maintainability and clarity of the codebase, making it easier for developers to navigate and understand the logic within various functions. Additionally, minor adjustments were made to logging messages for better clarity.
…onent

Updated the visibility condition in the Navigation component to ensure it only evaluates when there are yearly report rounds available. This change improves the logic by preventing unnecessary checks and enhances code clarity, making it easier to understand the conditions under which the navigation items are displayed.
…nd function

Enhanced the update_yearly_report_round function in data_access.py to include the ability to update the report year based on user input. This addition improves the functionality of the yearly report management by allowing for more flexible data handling.
Updated the BatchRabbitUpdateForm and BatchRabbitUpdateStep components to improve the handling of rabbit updates by introducing a reportRound state and refining the validation checks for weight and body fat measurements. Enhanced the filtering logic to ensure only relevant rabbits are included in the yearly report, considering their tracking and measurement validity. Additionally, refactored the UI to utilize radio buttons for body fat selection, improving user experience. These changes aim to streamline the update process and enhance data integrity for rabbit records.
…inability

This commit removes unnecessary console logging from the hasValidTrackingInPeriod and filterRabbitsForYearlyReport functions in the rabbit_filters module. The changes enhance code cleanliness and improve maintainability without altering the core functionality. These updates aim to streamline the codebase and improve performance by eliminating redundant debug statements.
…ling

Removed the 'public' option from the FieldWithPermission component and enforced 'authenticated' privacy level for all fields in the HerdContactUpdateStep. Enhanced form handling by replacing FieldWithPermission with TextField, improving user experience with clearer validation messages and background color indications for required fields. These changes streamline the privacy management and improve the overall clarity of the contact update process.
…andling

Added onUpdateStatus callback to BatchRabbitUpdateForm, BatchRabbitUpdateStep, HerdContactUpdateStep, SelectGenebankStep, SelectHerdStep, YearlyReportForm, YearlyReportMultiStepForm, and YearlyReportStep components to manage update statuses throughout the batch update process. Improved error handling and user feedback during updates, ensuring a smoother user experience. This enhancement allows for better tracking of the update process and improves overall functionality.
… conditions

Enhanced the Navigation component by sorting active report rounds by report year in descending order. Updated the visibility conditions to utilize the sorted list, ensuring that the correct report round data is displayed based on user roles (admin or owner). This refactor improves the logic and clarity of the navigation functionality.
Changed the primary key column name from "disease_id" to "yearly_herd_report_id" in the YearlyHerdReport model to better reflect its purpose and improve clarity in the database schema. This update enhances the consistency of the data model without altering any core functionality.
Modified the SelectHerdStep component to ensure that the onUpdateStatus callback is called only after breeding data is successfully loaded. This change improves the clarity of the code by removing premature status updates and enhances error handling by marking the status as "error" when data fetching fails. The dependency array for the useEffect hook has also been updated to include onUpdateStatus, ensuring proper function execution. These updates aim to improve the overall reliability and maintainability of the component.
Added validation checks in the save_yearly_report function to ensure that the report round is active, the report year matches, and that no existing reports exist for the specified herd in the given year. These enhancements improve data integrity and prevent duplicate submissions, ensuring a more robust reporting process.
… for report submissions

Improved date handling in the YearlyReportRounds component by adding validation checks to ensure both start and end dates are provided and that they are in the correct order. Implemented user messages to inform users of validation errors, enhancing the user experience and preventing incorrect submissions. These changes aim to improve data integrity and usability in the reporting process.
…alization

Modified the Manage component to ensure genebank IDs are returned as strings for consistency. Enhanced the user topic initialization logic to account for user roles, ensuring that the correct default genebank is set based on admin and manager status. This improves the reliability of the component and enhances user experience by providing appropriate defaults.
- Added cache directory to the application configuration for better cache management.
- Updated Docker Compose and production YAML files to include a cache volume for improved performance.
- Enhanced the .gitignore file to exclude cache files.
- Refactored the Restricted component in the frontend to improve user authorization handling and loading state management.

These changes aim to streamline the application setup and enhance user experience by ensuring proper caching and authorization checks.
@jhagberg jhagberg merged commit 1377427 into develop Jan 2, 2025
14 of 28 checks passed
@jhagberg jhagberg deleted the feature/yearly-report2 branch January 2, 2025 19:39
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.

1 participant