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 #709

Merged
merged 5 commits into from
Dec 28, 2024
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

@jhagberg jhagberg requested a review from Copilot December 26, 2024 15:45

Choose a reason for hiding this comment

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

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

Files not reviewed (10)
  • .docker/frontend: Language not supported
  • frontend/package.json: Language not supported
  • frontend/src/manage.tsx: Evaluated as low risk
  • frontend/src/YearlyReportRounds.tsx: Evaluated as low risk
  • frontend/src/navigation.tsx: Evaluated as low risk
  • frontend/src/YearlyReportViewer.tsx: Evaluated as low risk
  • frontend/src/HerdContactUpdateStep.tsx: Evaluated as low risk
  • app/utils/database.py: Evaluated as low risk
  • app/utils/data_access.py: Evaluated as low risk
  • frontend/src/YearlyReportMultiStepForm.tsx: Evaluated as low risk
Comments suppressed due to low confidence (7)

frontend/src/SelectHerdStep.tsx:36

  • Include 'genebankName' and 'user' in the dependency array to ensure herd options are updated correctly.
useEffect(() => { ... }, []);

frontend/src/SelectHerdStep.tsx:54

  • Include 'herdId' and 'reportYear' in the dependency array to ensure breedings are fetched correctly.
useEffect(() => { ... }, []);

frontend/src/BatchRabbitUpdateStep.tsx:22

  • The type 'any' for 'skippedRabbits' is too generic and should be replaced with a more specific type.
const [skippedRabbits, setSkippedRabbits] = useState<any[]>([]);

frontend/src/BatchRabbitUpdateStep.tsx:37

  • The type 'any' for 'individual' in the 'filter' function is too generic and should be replaced with a more specific type.
const rabbitsWithStatus = individualsData.filter((individual: any) => {

frontend/src/BatchRabbitUpdateStep.tsx:48

  • The type 'any' for 'acc' in the 'reduce' function is too generic and should be replaced with a more specific type.
const { needUpdate, canSkip } = rabbitsWithStatus.reduce((acc: { needUpdate: any[]; canSkip: any[] }, rabbit: any) => {

frontend/src/BatchRabbitUpdateStep.tsx:103

  • The type 'any' for 'rabbit' in the 'map' function is too generic and should be replaced with a more specific type.
{skippedRabbits.map((rabbit: any) => {

app/herdbook.py:1336

  • Add exception handling for the case where 'report_round' is not found.
report_round = da.YearlyReportRound.get_by_id(round_id)
@jhagberg jhagberg requested a review from Copilot December 26, 2024 22:10
Copy link

@Copilot 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.

Copilot reviewed 10 out of 24 changed files in this pull request and generated 1 comment.

Files not reviewed (14)
  • .docker/frontend: Language not supported
  • frontend/package.json: Language not supported
  • frontend/src/style.css: Language not supported
  • frontend/tsconfig.json: Language not supported
  • app/herdbook.py: Evaluated as low risk
  • frontend/src/navigation.tsx: Evaluated as low risk
  • frontend/src/manage.tsx: Evaluated as low risk
  • frontend/src/breeding_form.tsx: Evaluated as low risk
  • .github/workflows/create_packages.yml: Evaluated as low risk
  • frontend/src/YearlyReportViewer.tsx: Evaluated as low risk
  • frontend/src/YearlyReportStep.tsx: Evaluated as low risk
  • app/tests/test_database.py: Evaluated as low risk
  • frontend/src/YearlyReportRounds.tsx: Evaluated as low risk
  • frontend/src/HerdContactUpdateStep.tsx: Evaluated as low risk
Comments suppressed due to low confidence (2)

app/utils/data_access.py:2450

  • [nitpick] Ensure that error messages provide enough context. For example, 'Failed to save report' could be more specific.
logger.error(f"Failed to export yearly reports as CSV: {str(e)}")

app/utils/data_access.py:2265

  • The user variable is fetched but not used. Remove this redundant code.
user = fetch_user_info(user_uuid)

app/utils/data_access.py Outdated Show resolved Hide resolved
@jhagberg jhagberg changed the base branch from develop to test-prod December 28, 2024 09:20
@jhagberg jhagberg merged commit 06aaef5 into test-prod Dec 28, 2024
16 of 25 checks passed
@jhagberg jhagberg deleted the feature/yearly-report branch December 28, 2024 09:25
…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.
…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.
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