Skip to content

Commit

Permalink
Merge branch 'main' into 804-update-clubs-model
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettladley authored May 31, 2024
2 parents ac90e21 + 948b0fe commit 06c0789
Show file tree
Hide file tree
Showing 76 changed files with 3,335 additions and 20,186 deletions.
5 changes: 5 additions & 0 deletions backend/config/search.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package config

type SearchSettings struct {
URI string `env:"URI"`
}
3 changes: 3 additions & 0 deletions backend/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Integrations struct {
OutlookOauth OAuthSettings
AWS AWSSettings
Resend ResendSettings
Search SearchSettings
}

type intermediateSettings struct {
Expand All @@ -32,6 +33,7 @@ type intermediateSettings struct {
calendar intermediateCalendarSettings `envPrefix:"SAC_CALENDAR_"`
googleSettings intermediateGoogleOAuthSettings `envPrefix:"SAC_GOOGLE_OAUTH"`
outlookSettings intermdeiateOutlookOAuthSettings `envPrefix:"SAC_OUTLOOK_OAUTH"`
search SearchSettings `env:"SAC_SEARCH"`
}

func (i *intermediateSettings) into() (*Settings, error) {
Expand Down Expand Up @@ -104,6 +106,7 @@ func (i *intermediateSettings) into() (*Settings, error) {
OutlookOauth: *outlook,
AWS: *aws,
Resend: *resend,
Search: i.search,
},
}, nil
}
9 changes: 5 additions & 4 deletions backend/constants/search.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package constants

const (
SEARCH_URL = "http://127.0.0.1:9200"
CLUBS_INDEX = "clubs"
EVENTS_INDEX = "events"
SEARCH_QUERY_DEFAULT_MAX_MEMBERS = 16384
CLUBS_INDEX string = "clubs"
EVENTS_INDEX string = "events"
SEARCH_QUERY_DEFAULT_MAX_MEMBERS int = 16384
)

var SEARCH_URI string
4 changes: 2 additions & 2 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/GenerateNU/sac/backend
go 1.22.2

require (
github.com/a-h/templ v0.2.697
github.com/a-h/templ v0.2.707
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/aws/aws-sdk-go v1.53.8
github.com/aws/aws-sdk-go v1.53.10
github.com/garrettladley/fiberpaginate v1.0.5
github.com/garrettladley/mattress v0.4.0
github.com/go-playground/validator/v10 v10.20.0
Expand Down
8 changes: 4 additions & 4 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/a-h/templ v0.2.697 h1:OILxtWvD0NRJaoCOiZCopRDPW8paroKlGsrAiHLykNE=
github.com/a-h/templ v0.2.697/go.mod h1:5cqsugkq9IerRNucNsI4DEamdHPsoGMQy99DzydLhM8=
github.com/a-h/templ v0.2.707 h1:T1Gkd2ugbRglZ9rYw/VBchWOSZVKmetDbBkm4YubM7U=
github.com/a-h/templ v0.2.707/go.mod h1:5cqsugkq9IerRNucNsI4DEamdHPsoGMQy99DzydLhM8=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
Expand All @@ -14,8 +14,8 @@ github.com/awnumar/memcall v0.2.0 h1:sRaogqExTOOkkNwO9pzJsL8jrOV29UuUW7teRMfbqtI
github.com/awnumar/memcall v0.2.0/go.mod h1:S911igBPR9CThzd/hYQQmTc9SWNu3ZHIlCGaWsWsoJo=
github.com/awnumar/memguard v0.22.5 h1:PH7sbUVERS5DdXh3+mLo8FDcl1eIeVjJVYMnyuYpvuI=
github.com/awnumar/memguard v0.22.5/go.mod h1:+APmZGThMBWjnMlKiSM1X7MVpbIVewen2MTkqWkA/zE=
github.com/aws/aws-sdk-go v1.53.8 h1:eoqGb1WOHIrCFKo1d51cMcnt1ralfLFaEqRkC5Zzv8k=
github.com/aws/aws-sdk-go v1.53.8/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.53.10 h1:3enP5l5WtezT9Ql+XZqs56JBf5YUd/FEzTCg///OIGY=
github.com/aws/aws-sdk-go v1.53.10/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
Expand Down
3 changes: 3 additions & 0 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path/filepath"

"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"
_ "github.com/GenerateNU/sac/backend/docs"
Expand All @@ -32,6 +33,8 @@ func main() {
utilities.Exit("Error getting configuration: %s", err.Error())
}

constants.SEARCH_URI = config.Search.URI

err = checkServerRunning(config.Application.Host, config.Application.Port)
if err == nil {
utilities.Exit("A server is already running on %s:%d.\n", config.Application.Host, config.Application.Port)
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 @@ -21,7 +21,7 @@ func doSearchGetRequest[T, V any](url string, requestBody T) (*V, error) {
return nil, err
}

resp, err := utilities.Request(http.MethodGet, fmt.Sprintf("%s%s", constants.SEARCH_URL, url), payload, utilities.JSON())
resp, err := utilities.Request(http.MethodGet, fmt.Sprintf("%s%s", constants.SEARCH_URI, url), payload, utilities.JSON())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -80,7 +80,7 @@ func Upsert[T types.Searchable](db *gorm.DB, index string, uuid string, model ty
return err
}

resp, err := utilities.Request(http.MethodPost, fmt.Sprintf("%s/%s/_update/%s", constants.SEARCH_URL, index, uuid), payload, utilities.JSON())
resp, err := utilities.Request(http.MethodPost, fmt.Sprintf("%s/%s/_update/%s", constants.SEARCH_URI, index, uuid), payload, utilities.JSON())
if err != nil {
return err
}
Expand All @@ -90,7 +90,7 @@ func Upsert[T types.Searchable](db *gorm.DB, index string, uuid string, model ty
}

func Delete(db *gorm.DB, index string, uuid string) error {
resp, err := utilities.Request(http.MethodDelete, fmt.Sprintf("%s/%s/_doc/%s", constants.SEARCH_URL, index, uuid), nil, utilities.JSON())
resp, err := utilities.Request(http.MethodDelete, fmt.Sprintf("%s/%s/_doc/%s", constants.SEARCH_URI, index, uuid), nil, utilities.JSON())
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions backend/search/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func SeedClubs(db *gorm.DB) error {
stdout := os.Stdout

stdout.WriteString("Deleting existing club index...\n")
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/clubs", constants.SEARCH_URL), nil)
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/clubs", constants.SEARCH_URI), nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -58,7 +58,7 @@ func SeedClubs(db *gorm.DB) error {
requestBodyBuilder.WriteString(fmt.Sprintf("%s\n%s\n", indexJson, clubJson))
}

resp, err := utilities.Request(http.MethodPost, fmt.Sprintf("%s/_bulk", constants.SEARCH_URL), []byte(requestBodyBuilder.String()), utilities.JSON())
resp, err := utilities.Request(http.MethodPost, fmt.Sprintf("%s/_bulk", constants.SEARCH_URI), []byte(requestBodyBuilder.String()), utilities.JSON())
if err != nil {
stdout.WriteString(fmt.Sprintf("Error making _bulk request for club seeding: %s\n", err.Error()))
}
Expand All @@ -78,7 +78,7 @@ func SeedEvents(db *gorm.DB) error {
stdout := os.Stdout

stdout.WriteString("Deleting existing event index...\n")
resp, err := utilities.Request(http.MethodDelete, fmt.Sprintf("%s/events", constants.SEARCH_URL), nil, utilities.JSON())
resp, err := utilities.Request(http.MethodDelete, fmt.Sprintf("%s/events", constants.SEARCH_URI), nil, utilities.JSON())
if err != nil {
return err
}
Expand Down Expand Up @@ -109,7 +109,7 @@ func SeedEvents(db *gorm.DB) error {
requestBodyBuilder.WriteString(fmt.Sprintf("%s\n%s\n", indexJson, eventJson))
}

resp, err = utilities.Request(http.MethodPost, fmt.Sprintf("%s/_bulk", constants.SEARCH_URL), []byte(requestBodyBuilder.String()), utilities.JSON())
resp, err = utilities.Request(http.MethodPost, fmt.Sprintf("%s/_bulk", constants.SEARCH_URI), []byte(requestBodyBuilder.String()), utilities.JSON())
if err != nil {
stdout.WriteString(fmt.Sprintf("Error making _bulk request for event seeding: %s\n", err.Error()))
}
Expand Down
2 changes: 1 addition & 1 deletion cli/helpers/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func DownDB() error {
return err
}

// #nosec G204 -- MIGRATIONS is a constant file path configured in cli/commands/config.go and config.Database.PostgresConn() is configured by the config/local.yml
// #nosec G204 -- MIGRATIONS is a constant file path configured in cli/commands/config.go and config.Database.PostgresConn() is configured in config/
cmd := exec.Command("migrate", "-path", MIGRATIONS, "-database", config.Database.PostgresConn(), "-verbose", "down", "-all")

cmd.Dir = ROOT_DIR
Expand Down
2 changes: 2 additions & 0 deletions config/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ SAC_GOOGLE_OAUTH_REDIRECT_URI="http://127.0.0.1:3000"
SAC_OUTLOOK_OAUTH_CLIENT_ID=test
SAC_OUTLOOK_OAUTH_CLIENT_SECRET=test
SAC_OUTLOOK_OAUTH_REDIRECT_URI="http://127.0.0.1:3000

SAC_SEARCH_URI=""http://127.0.0.1:9200"
34 changes: 0 additions & 34 deletions config/local.yml

This file was deleted.

4 changes: 0 additions & 4 deletions config/production.yml

This file was deleted.

36 changes: 0 additions & 36 deletions frontend/dashboard/const/dummyConst.ts

This file was deleted.

Loading

0 comments on commit 06c0789

Please sign in to comment.