@@ -25,7 +25,7 @@ func NewOpportunityRepository(db *gorm.DB, logger *zerolog.Logger) models.Opport
2525// FindByID finds a single entity by ID.
2626func (r * opportunityRepository ) FindByID (ctx context.Context , id int64 ) (* models.Opportunity , error ) {
2727 var opportunity models.Opportunity
28- if err := r .db .Preload ("OpportunityRequirements" ).Preload ("OpportunityLimits" ).First (& opportunity , id ).Error ; err != nil {
28+ if err := r .db .Preload ("OpportunityRequirements" ).Preload ("OpportunityLimits" ).Preload ( "OpportunityTags" ). Preload ( "OpportunityTags.Tag" ). First (& opportunity , id ).Error ; err != nil {
2929 return & opportunity , err
3030 }
3131 return & opportunity , nil
@@ -34,7 +34,7 @@ func (r *opportunityRepository) FindByID(ctx context.Context, id int64) (*models
3434// FindByIDs finds multiple entities by an array of IDs.
3535func (r * opportunityRepository ) FindByIDs (ctx context.Context , ids []int64 ) ([]models.Opportunity , error ) {
3636 var opportunities []models.Opportunity
37- if err := r .db .Preload ("OpportunityRequirements" ).Preload ("OpportunityLimits" ).
37+ if err := r .db .Preload ("OpportunityRequirements" ).Preload ("OpportunityLimits" ).Preload ( "OpportunityTags" ). Preload ( "OpportunityTags.Tag" ).
3838 Where ("id IN (?) AND active = True" , ids ).
3939 Find (& opportunities ).
4040 Error ; err != nil {
@@ -46,7 +46,7 @@ func (r *opportunityRepository) FindByIDs(ctx context.Context, ids []int64) ([]m
4646// FindByOrganizationID finds multiple entities by the organization ID.
4747func (r * opportunityRepository ) FindByOrganizationID (ctx context.Context , organizationID int64 ) ([]models.Opportunity , error ) {
4848 var opportunities []models.Opportunity
49- if err := r .db .Preload ("OpportunityRequirements" ).Preload ("OpportunityLimits" ).
49+ if err := r .db .Preload ("OpportunityRequirements" ).Preload ("OpportunityLimits" ).Preload ( "OpportunityTags" ). Preload ( "OpportunityTags.Tag" ).
5050 Limit (dbctx .Get (ctx ).Limit ).
5151 Offset (dbctx .Get (ctx ).Page * dbctx .Get (ctx ).Limit ).
5252 Where ("organization_id = ? AND active = True AND LOWER(title) LIKE ?" , organizationID , strings .ToLower (fmt .Sprintf ("%%%s%%" , dbctx .Get (ctx ).Query ))).
@@ -60,7 +60,7 @@ func (r *opportunityRepository) FindByOrganizationID(ctx context.Context, organi
6060// FindByCreatorID finds multiple entities by the creator ID.
6161func (r * opportunityRepository ) FindByCreatorID (ctx context.Context , creatorID int64 ) ([]models.Opportunity , error ) {
6262 var opportunities []models.Opportunity
63- if err := r .db .Preload ("OpportunityRequirements" ).Preload ("OpportunityLimits" ).Where ("creator_id = ? AND active = True" , creatorID ).Find (& opportunities ).Error ; err != nil {
63+ if err := r .db .Preload ("OpportunityRequirements" ).Preload ("OpportunityLimits" ).Preload ( "OpportunityTags" ). Preload ( "OpportunityTags.Tag" ). Where ("creator_id = ? AND active = True" , creatorID ).Find (& opportunities ).Error ; err != nil {
6464 return opportunities , err
6565 }
6666 return opportunities , nil
0 commit comments