Skip to content

Commit

Permalink
fix ci issues
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-brennan2005 committed Jun 20, 2024
1 parent ab18b09 commit 8c52d4a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
20 changes: 18 additions & 2 deletions backend/entities/clubs/base/service.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package base

import (
"log/slog"

"github.com/GenerateNU/sac/backend/entities/clubs"
"github.com/GenerateNU/sac/backend/entities/models"
"github.com/GenerateNU/sac/backend/errs"
Expand Down Expand Up @@ -46,7 +48,14 @@ func (c *ClubService) CreateClub(userID uuid.UUID, clubBody CreateClubRequestBod
return nil, err
}

go search.UpsertClubEmbedding(c.DB, c.Search, result)
go func() {
err := search.UpsertClubEmbedding(c.DB, c.Search, result)

if err != nil {
slog.Error("Upsert club embedding failed")
}
}()

return result, err
}

Expand Down Expand Up @@ -83,7 +92,14 @@ func (c *ClubService) UpdateClub(id string, clubBody UpdateClubRequestBody) (*mo
return nil, err
}

go search.UpsertClubEmbedding(c.DB, c.Search, result)
go func() {
err := search.UpsertClubEmbedding(c.DB, c.Search, result)

if err != nil {
slog.Error("Upsert club embedding failed")
}
}()

return UpdateClub(c.DB, *idAsUUID, *club)
}

Expand Down
18 changes: 16 additions & 2 deletions backend/entities/events/base/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package base

import (
"errors"
"log/slog"

"github.com/GenerateNU/sac/backend/entities/events"
"github.com/GenerateNU/sac/backend/entities/models"
Expand Down Expand Up @@ -71,7 +72,13 @@ func (e *EventService) CreateEvent(body events.CreateEventRequestBody) (*models.
return nil, err
}

go search.UpsertEventEmbedding(e.DB, e.Search, result)
go func() {
err := search.UpsertEventEmbedding(e.DB, e.Search, result)

if err != nil {
slog.Error("Upsert club embedding failed")
}
}()
return result, err
}

Expand All @@ -95,7 +102,14 @@ func (e *EventService) UpdateEvent(eventID string, eventBody events.UpdateEventR
return nil, err
}

go search.UpsertEventEmbedding(e.DB, e.Search, &result[0])
go func() {
err := search.UpsertEventEmbedding(e.DB, e.Search, &result[0])

if err != nil {
slog.Error("Upsert club embedding failed")
}
}()

return result, err
}

Expand Down
6 changes: 3 additions & 3 deletions backend/search/base/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
"gorm.io/gorm"
)

// Use this over strings.join so elements can be single quoted if nessecary.
func joinQuoted(elems []string, seperator string) string {
// Use this over strings.join so elements can be single quoted if necessary.
func joinQuoted(elems []string, separator string) string {
elemsQuoted := make([]string, len(elems))

for i, elem := range elems {
elemsQuoted[i] = fmt.Sprintf("'%s'", elem)
}

return strings.Join(elemsQuoted, seperator)
return strings.Join(elemsQuoted, separator)
}

func SearchClubs(db *gorm.DB, s *config.SearchSettings, query *types.ClubSearchRequest) (*types.SearchResult[models.Club], error) {
Expand Down

0 comments on commit 8c52d4a

Please sign in to comment.