diff --git a/backend/constants/search.go b/backend/constants/search.go deleted file mode 100644 index 69bdd828..00000000 --- a/backend/constants/search.go +++ /dev/null @@ -1,9 +0,0 @@ -package constants - -const ( - CLUBS_INDEX string = "clubs" - EVENTS_INDEX string = "events" - SEARCH_QUERY_DEFAULT_MAX_MEMBERS int = 16384 -) - -var SEARCH_URI string diff --git a/backend/entities/models/club.go b/backend/entities/models/club.go index 5aa2015c..f2ce32e1 100644 --- a/backend/entities/models/club.go +++ b/backend/entities/models/club.go @@ -35,30 +35,3 @@ type Club struct { Event []Event `gorm:"many2many:club_events;" json:"-"` Notification []Notification `gorm:"polymorphic:Reference;" json:"-"` } - -type ClubSearchDocument struct { - Name string `json:"name"` - Preview string `json:"preview"` - Description string `json:"description"` - NumMembers int `json:"num_members"` - Tags []string `json:"tags"` -} - -func (c *Club) ToSearchDocument() interface{} { - tagIds := make([]string, len(c.Tag)) - for i, tag := range c.Tag { - tagIds[i] = tag.ID.String() - } - - return ClubSearchDocument{ - Name: c.Name, - Preview: c.Preview, - Description: c.Description, - NumMembers: c.NumMembers, - Tags: tagIds, - } -} - -func (c Club) Preload(db *gorm.DB) *gorm.DB { - return db.Preload("Tag") -} diff --git a/backend/entities/models/event.go b/backend/entities/models/event.go index edf5395a..12eb1b0f 100644 --- a/backend/entities/models/event.go +++ b/backend/entities/models/event.go @@ -4,7 +4,6 @@ import ( "time" "github.com/google/uuid" - "gorm.io/gorm" ) type EventType string @@ -48,42 +47,3 @@ type Event struct { Tag []Tag `gorm:"many2many:event_tags;" json:"-"` Notification []Notification `gorm:"polymorphic:Reference;" json:"-"` } - -// How Events are represented in the OpenSearch index. -type EventSearchDocument struct { - Name string `json:"name"` - Preview string `json:"preview"` - Description string `json:"description"` - EventType EventType `json:"event_type"` - StartTime time.Time `json:"start_time"` - EndTime time.Time `json:"end_time"` - Clubs []string `json:"clubs"` - Tags []string `json:"tags"` -} - -func (c *Event) ToSearchDocument() interface{} { - tagIds := make([]string, len(c.Tag)) - for i, tag := range c.Tag { - tagIds[i] = tag.ID.String() - } - - clubIds := make([]string, len(c.Clubs)) - for i, club := range c.Clubs { - clubIds[i] = club.ID.String() - } - - return EventSearchDocument{ - Name: c.Name, - Preview: c.Preview, - Description: c.Description, - EventType: c.EventType, - StartTime: c.StartTime, - EndTime: c.EndTime, - Tags: tagIds, - Clubs: clubIds, - } -} - -func (c Event) Preload(db *gorm.DB) *gorm.DB { - return db.Preload("Tag").Preload("Club") -} diff --git a/backend/main.go b/backend/main.go index 65a6e778..241fc1a9 100644 --- a/backend/main.go +++ b/backend/main.go @@ -15,7 +15,6 @@ import ( "github.com/GenerateNU/sac/backend/background" "github.com/GenerateNU/sac/backend/background/jobs" "github.com/GenerateNU/sac/backend/config" - "github.com/GenerateNU/sac/backend/constants" "github.com/GenerateNU/sac/backend/database" "github.com/GenerateNU/sac/backend/database/store" @@ -35,14 +34,12 @@ import ( ) func main() { - onlyMigrate, seedSearch, configPath := parseFlags() + onlyMigrate, configPath := parseFlags() config, err := config.GetConfiguration(*configPath) if err != nil { utilities.Exit("Error getting configuration: %s", err.Error()) } - constants.SEARCH_URI = config.Search.URI - if checkServerRunning(config.Application.Host, config.Application.Port) == nil { utilities.Exit("A server is already running on %s:%d.\n", config.Application.Host, config.Application.Port) } @@ -58,10 +55,6 @@ func main() { return } - if *seedSearch { - seedSearchData(db) - } - if err := database.ConnPooling(db); err != nil { utilities.Exit("Error with connection pooling: %s", err.Error()) } @@ -82,9 +75,8 @@ func main() { waitForShutdown(app) } -func parseFlags() (onlyMigrate, seedSearch *bool, configPath *string) { +func parseFlags() (onlyMigrate *bool, configPath *string) { onlyMigrate = flag.Bool("only-migrate", false, "Specify if you want to only perform the database migration") - seedSearch = flag.Bool("seed-search", true, "Specify if you want to seed the opensearch nodes.") configPath = flag.String("config", filepath.Join("..", "config", ".env.dev"), "Specify the path to the config file (.env)") flag.Parse() return @@ -100,17 +92,6 @@ func checkServerRunning(host string, port uint16) error { return nil } -func seedSearchData(db *gorm.DB) { - slog.Info("to appease linter", "seedSearch", true, "db", db) - // if err := search.SeedClubs(db); err != nil { - // return - // } - - // if err := search.SeedEvents(db); err != nil { - // return - // } -} - func startBackgroundJobs(ctx context.Context, db *gorm.DB) { jobs := jobs.New(db) background.Go(jobs.WelcomeSender(ctx))