-
Notifications
You must be signed in to change notification settings - Fork 48
[SPRINT-M25] feature: added feedback stats #195
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
Conversation
|
@Jagath-P is attempting to deploy a commit to the openlake's projects Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughImplements a tenure-aware FeedbackStats component, adds getCurrentTenureRange utility, refactors fetch logic in useFeedback into a named function, and applies a minor formatting change to FeedbackForm without functional impact. Changes
Sequence Diagram(s)sequenceDiagram
participant Stats as FeedbackStats
participant Context as AdminContext
participant Tenure as getCurrentTenureRange
participant Hook as useFeedback
participant API as Backend API
Stats->>Context: useContext() (get role/admin flag)
Stats->>Tenure: getCurrentTenureRange()
Tenure-->>Stats: { startDate, endDate, tenureYearString }
Stats->>Hook: useFeedback()
Hook->>API: fetchFeedback() (named fn)
API-->>Hook: feedback[]
Hook-->>Stats: feedback, loading, error
Stats->>Stats: filter by start/end dates, compute total, pending, resolved, recent(30d), avg rating
Stats->>Stats: render stats block
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Attention points:
Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (6)
frontend/src/Components/Feedback/FeedbackStats.jsx (4)
2-2: Remove unused import.
useStateis imported but never used in this component.Apply this diff:
-import { useState, useContext } from "react"; +import { useContext } from "react";
7-15: Remove unused destructured values.Many values are destructured from
useFeedback()but never used:loading,activeTab,setActiveTab,statusFilter,setStatusFilter, andmarkAsResolved. OnlyfilteredFeedbacksis actually utilized.Apply this diff:
- const { - loading, - activeTab, - setActiveTab, - statusFilter, - setStatusFilter, - filteredFeedbacks, - markAsResolved, - } = useFeedback(); + const { filteredFeedbacks } = useFeedback();
16-16: Remove unused variable from destructuring.
tenureYearStringis destructured but never used in the component.Apply this diff:
- const { startDate, endDate, tenureYearString } = getCurrentTenureRange(); + const { startDate, endDate } = getCurrentTenureRange();
21-22: Remove unused isStudent computation.The
isStudentflag is computed but never used in the component. If this is for future functionality, consider adding it when needed.Apply this diff to remove the unused code:
- const { isUserLoggedIn } = useContext(AdminContext); - const isStudent = isUserLoggedIn?.role === "STUDENT"; -frontend/src/utils/getCurrentTenureRange.js (2)
19-19: Use ES6 export syntax for consistency.The file uses CommonJS
module.exportswhile the rest of the frontend codebase uses ES6import/exportsyntax. Although most bundlers handle this, maintaining consistency improves code clarity.Apply this diff:
-module.exports = getCurrentTenureRange; +export default getCurrentTenureRange;
1-17: Note: Code duplication with backend utility.The relevant code snippets show that
backend/utils/getTenureRange.jscontains nearly identical logic. While some duplication between frontend and backend is acceptable (separate environments), consider whether this logic could be shared via a common package or if the calculation should be performed server-side and exposed via API to ensure consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
frontend/src/Components/Feedback/FeedbackForm.jsx(1 hunks)frontend/src/Components/Feedback/FeedbackStats.jsx(1 hunks)frontend/src/hooks/useFeedback.js(1 hunks)frontend/src/utils/getCurrentTenureRange.js(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
frontend/src/hooks/useFeedback.js (1)
frontend/src/utils/api.js (1)
api(2-5)
frontend/src/Components/Feedback/FeedbackForm.jsx (1)
frontend/src/hooks/useFeedback.js (2)
filteredTargets(86-86)formData(87-94)
frontend/src/Components/Feedback/FeedbackStats.jsx (2)
frontend/src/hooks/useFeedback.js (5)
useFeedback(8-77)useFeedback(8-77)filteredFeedbacks(35-44)useContext(13-13)useContext(95-95)frontend/src/utils/getCurrentTenureRange.js (3)
getCurrentTenureRange(1-17)startDate(6-6)now(2-2)
frontend/src/utils/getCurrentTenureRange.js (2)
frontend/src/Components/Feedback/FeedbackStats.jsx (1)
getCurrentTenureRange(16-16)backend/utils/getTenureRange.js (1)
now(1-17)
🔇 Additional comments (3)
frontend/src/Components/Feedback/FeedbackForm.jsx (1)
118-122: LGTM! Formatting improves readability.The multi-line formatting of the Select value expression enhances code readability without changing the logic.
frontend/src/utils/getCurrentTenureRange.js (1)
1-17: Logic looks correct for April-March fiscal year.The tenure range calculation correctly handles the 3-month cutoff (January-March) and computes the appropriate start and end dates for an April 1 to March 31 tenure period.
frontend/src/hooks/useFeedback.js (1)
15-27: LGTM! Good refactoring.Extracting
fetchFeedbackas a named function improves code organization and reusability while preserving the original behavior (API call, sorting, error handling, and loading state management).
|
@Jagath-P pls make changes suggested by coderabbit |
name: " Pull Request"
about: Propose and submit changes to the project for review
title: "PR: Updated the feedback stats section "
labels: ""
assignees: harshitap1305, sakshi1755
Related Issue
Changes Introduced
Screenshots / Video (if applicable)
now

@harshitap1305 for review
💬 Additional Notes
Summary by CodeRabbit
New Features
Refactor