Skip to content

Conversation

@VishakhaSainani-Josh
Copy link
Collaborator

@VishakhaSainani-Josh VishakhaSainani-Josh commented Jul 17, 2025

  1. Allow user to set goal level
  2. Allow user to view selected level's target
  3. Allow user to set custom targets

Summary by Bito

This pull request implements a new goal service enabling users to set goal levels, view targets, and create custom targets. It introduces domain models, service logic, API endpoints, and repository methods for goal management while enhancing the user service to support updating active goals. The changes integrate seamlessly with existing components and improve error handling.

@bito-code-review
Copy link

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
New Feature - Introduction of New Goal Service Functionality

dependencies.go - Integrated goal dependency injection by adding GoalHandler and related service instantiation.

domain.go - Established new domain models for goals and goal contributions.

handler.go - Implemented API endpoints to list goal levels, fetch targets, create custom targets, and list achieved targets.

service.go - Defined business logic for handling goal operations and managing custom targets.

router.go - Added new routing endpoints for goal-related operations and integrated them with authentication middleware.

handler.go - Extended user handler with a new method to update the current active goal based on user input.

service.go - Enhanced user service to support updating the current active goal by integrating with the goal service.

domain.go - Expanded repository domain by adding goal and goal contribution structures for persistent storage.

goal.go - Introduced a new goal repository with functions to list goal levels, retrieve goal IDs, and create custom goal level targets.

user.go - Added functionality to update a user's current active goal id with appropriate error handling.

Feature Improvement - Enhancements in Contribution Repository

contribution.go - Added functionality to retrieve contribution type by contribution score ID and refined monthly summary queries.

Other Improvements - Refactoring and Error Handling Updates

domain.go - Refactored Transaction struct by removing db tag annotations for uniformity.

domain.go - Updated User domain definitions, including Transaction and LeaderboardUser, by removing db tags.

errors.go - Added new error definitions for goal-related operations and custom goal target creation.

Copy link

@bito-code-review bito-code-review bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #463da1

Actionable Suggestions - 3
  • internal/app/goal/service.go - 1
  • internal/app/transaction/domain.go - 1
    • Missing database struct tags break sqlx operations · Line 6-14
  • internal/repository/goal.go - 1
    • Incorrect error handling for empty results · Line 98-98
Review Details
  • Files reviewed - 14 · Commit Range: a1b4689..4db322e
    • internal/app/dependencies.go
    • internal/app/goal/domain.go
    • internal/app/goal/handler.go
    • internal/app/goal/service.go
    • internal/app/router.go
    • internal/app/transaction/domain.go
    • internal/app/user/domain.go
    • internal/app/user/handler.go
    • internal/app/user/service.go
    • internal/pkg/apperrors/errors.go
    • internal/repository/contribution.go
    • internal/repository/domain.go
    • internal/repository/goal.go
    • internal/repository/user.go
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at vishwajeetsingh@joshsoftware.com.

Documentation & Help

AI Code Review powered by Bito Logo

return 0, err
}

return goalId, err

Choose a reason for hiding this comment

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

Incorrect error return on success

The GetGoalIdByGoalLevel function returns err instead of nil on successful execution. This will cause the function to always return an error, breaking all callers. Change return goalId, err to return goalId, nil.

Code suggestion
Check the AI-generated fix before applying
Suggested change
return goalId, err
return goalId, nil

Code Review Run #463da1


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment on lines +6 to +14
Id int
UserId int
ContributionId int
IsRedeemed bool
IsGained bool
TransactedBalance int
TransactedAt time.Time
CreatedAt time.Time
UpdatedAt time.Time

Choose a reason for hiding this comment

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

Missing database struct tags break sqlx operations

The db struct tags have been removed from all Transaction struct fields. This will break database operations since the repository layer uses sqlx.GetContext() which relies on these tags to map database columns to struct fields. Please restore all db tags: db:"id", db:"user_id", db:"contribution_id", db:"is_redeemed", db:"is_gained", db:"transacted_balance", db:"transacted_at", db:"created_at", db:"updated_at".

Code suggestion
Check the AI-generated fix before applying
Suggested change
Id int
UserId int
ContributionId int
IsRedeemed bool
IsGained bool
TransactedBalance int
TransactedAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
Id int `db:"id"`
UserId int `db:"user_id"`
ContributionId int `db:"contribution_id"`
IsRedeemed bool `db:"is_redeemed"`
IsGained bool `db:"is_gained"`
TransactedBalance int `db:"transacted_balance"`
TransactedAt time.Time `db:"transacted_at"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`

Code Review Run #463da1


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

}

slog.Error("error occured while getting goal id by goal level", "error", err)
return nil, apperrors.ErrInternalServer

Choose a reason for hiding this comment

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

Incorrect error handling for empty results

The ListUserGoalLevelTargets function incorrectly handles sql.ErrNoRows by returning ErrInternalServer. For SelectContext operations, no rows is a valid scenario that should return an empty slice []GoalContribution{} instead of an error. This will cause incorrect 500 errors when users have no goal level targets.

Code suggestion
Check the AI-generated fix before applying
Suggested change
return nil, apperrors.ErrInternalServer
return []GoalContribution{}, nil

Code Review Run #463da1


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

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.

3 participants