Skip to content

Commit

Permalink
Merge branch 'main' into email-verification
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOduneye committed Mar 18, 2024
2 parents a093be0 + f6e80e0 commit e9ab811
Show file tree
Hide file tree
Showing 52 changed files with 7,424 additions and 7,159 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Web

permissions: read-all

on:
push:
paths:
- frontend/sac-web/**
- .github/workflows/web.yml
pull_request:
types: opened
paths:
- frontend/sac-web/**
- .github/workflows/web.yml

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/sac-web/yarn.lock
- name: Install dependencies
run: |
cd frontend/sac-web
yarn install
- name: Format
run: |
cd frontend/sac-web
yarn format
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/sac-web/yarn.lock
- name: Install dependencies
run: |
cd frontend/sac-web
yarn install
- name: Lint
run: |
cd frontend/sac-web
yarn lint
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn
cache-dependency-path: frontend/sac-web/yarn.lock
- name: Install dependencies
run: |
cd frontend/sac-web
yarn install
- name: Test
run: |
cd frontend/sac-web
yarn test
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@
alt="Mobile CodeQL Workflow Status" />
</a>


<br />

<a href="https://github.com/GenerateNU/sac/actions/workflows/web.yml">
<img src="https://github.com/GenerateNU/sac/actions/workflows/web.yml/badge.svg"
alt="Web Workflow Status" />
</a>

<a href="https://github.com/GenerateNU/sac/actions/workflows/web_codeql.yml">
<img src="https://github.com/GenerateNU/sac/actions/workflows/web_codeql.yml/badge.svg"
Expand Down
8 changes: 5 additions & 3 deletions backend/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/GenerateNU/sac/backend

go 1.22.0
go 1.22.1

require (
github.com/clerkinc/clerk-sdk-go v1.49.0
Expand All @@ -21,16 +21,18 @@ require (
golang.org/x/crypto v0.21.0
golang.org/x/text v0.14.0
gorm.io/driver/postgres v1.5.7
gorm.io/gorm v1.25.7
gorm.io/gorm v1.25.8
)

require (
github.com/awnumar/memcall v0.2.0 // indirect
github.com/awnumar/memguard v0.22.4 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/tinylib/msgp v1.1.8 // indirect
golang.org/x/sync v0.6.0 // indirect
)

require (
Expand All @@ -48,7 +50,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.4.3 // indirect
github.com/jackc/pgx/v5 v5.5.4 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/joho/godotenv v1.5.1
Expand Down
12 changes: 8 additions & 4 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY=
github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
github.com/jackc/pgx/v5 v5.5.4 h1:Xp2aQS8uXButQdnCMWNmvx6UysWQQC+u1EoizjguY+8=
github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
Expand Down Expand Up @@ -185,6 +187,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -236,5 +240,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/postgres v1.5.7 h1:8ptbNJTDbEmhdr62uReG5BGkdQyeasu/FZHxI0IMGnM=
gorm.io/driver/postgres v1.5.7/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA=
gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.8 h1:WAGEZ/aEcznN4D03laj8DKnehe1e9gYQAjW8xyPRdeo=
gorm.io/gorm v1.25.8/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
38 changes: 35 additions & 3 deletions backend/src/controllers/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,14 @@ func (e *EventController) UpdateEvent(c *fiber.Ctx) error {
// UpdateSeriesByID godoc
//
// @Summary Update a series by ID
// @Description Updates a series by ID
// @Description Updates a series by ID. If individual events have been edited prior,
//
// this update will override the previous changes
//
// @ID update-series-by-id
// @Tags event
// @Accept json
// @Produce json
// @Param eventID path string true "Event ID"
// @Param seriesID path string true "Series ID"
// @Param seriesBody body models.UpdateSeriesRequestBody true "Series Body"
// @Success 200 {object} models.Series
Expand All @@ -192,7 +194,37 @@ func (e *EventController) UpdateSeriesByID(c *fiber.Ctx) error {
return errors.FailedToParseRequestBody.FiberError(c)
}

updatedSeries, err := e.eventService.UpdateSeries(c.Params("eventID"), c.Params("seriesID"), seriesBody)
updatedSeries, err := e.eventService.UpdateSeries(c.Params("seriesID"), seriesBody)
if err != nil {
return err.FiberError(c)
}

return c.Status(fiber.StatusOK).JSON(updatedSeries)
}

// UpdateSeriesByEventID godoc
//
// @Summary Update a series by event ID
// @Description Updates a series by event ID
// @ID update-series-by-event-id
// @Tags event
// @Accept json
// @Produce json
// @Param eventID path string true "Event ID"
// @Param seriesBody body models.UpdateSeriesRequestBody true "Series Body"
// @Success 200 {object} models.Series
// @Failure 400 {object} errors.Error
// @Failure 401 {object} errors.Error
// @Failure 404 {object} errors.Error
// @Failure 500 {object} errors.Error
// @Router /events/{eventID}/series/{seriesID}/ [patch]
func (e *EventController) UpdateSeriesByEventID(c *fiber.Ctx) error {
var seriesBody models.UpdateSeriesRequestBody
if err := c.BodyParser(&seriesBody); err != nil {
return errors.FailedToParseRequestBody.FiberError(c)
}

updatedSeries, err := e.eventService.UpdateSeriesByEventID(c.Params("eventID"), seriesBody)
if err != nil {
return err.FiberError(c)
}
Expand Down
3 changes: 2 additions & 1 deletion backend/src/database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package database
import (
"github.com/GenerateNU/sac/backend/src/config"
"github.com/GenerateNU/sac/backend/src/models"

"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
Expand Down Expand Up @@ -71,7 +70,9 @@ func MigrateDB(settings config.Settings, db *gorm.DB) error {
&models.Category{},
&models.Club{},
&models.Contact{},
&models.Series{},
&models.Event{},
&models.EventSeries{},
&models.Notification{},
&models.PointOfContact{},
&models.Tag{},
Expand Down
8 changes: 8 additions & 0 deletions backend/src/errors/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package errors
import "github.com/gofiber/fiber/v2"

var (
ClubSeedingFailed = Error{
StatusCode: fiber.StatusInternalServerError,
Message: "failed to seed pinecone with clubs",
}
FailedToCreateEmbedding = Error{
StatusCode: fiber.StatusInternalServerError,
Message: "failed to create embedding from string",
Expand All @@ -15,6 +19,10 @@ var (
StatusCode: fiber.StatusInternalServerError,
Message: "failed to delete from pinecone",
}
ItemsMustHaveSameNamespace = Error{
StatusCode: fiber.StatusInternalServerError,
Message: "items being deleted have differing namespaces",
}
FailedToSearchToPinecone = Error{
StatusCode: fiber.StatusInternalServerError,
Message: "failed to search on pinecone",
Expand Down
19 changes: 18 additions & 1 deletion backend/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/GenerateNU/sac/backend/src/config"
"github.com/GenerateNU/sac/backend/src/database"
_ "github.com/GenerateNU/sac/backend/src/docs"
"github.com/GenerateNU/sac/backend/src/search"
"github.com/GenerateNU/sac/backend/src/server"
)

Expand All @@ -30,6 +31,7 @@ func Exit(format string, a ...interface{}) {

func main() {
onlyMigrate := flag.Bool("only-migrate", false, "Specify if you want to only perform the database migration")
onlySeedPinecone := flag.Bool("seed-pinecone", false, "Specify if want to only perform the pinecone database seeding")
configPath := flag.String("config", filepath.Join("..", "..", "config"), "Specify the path to the config directory")
useDevDotEnv := flag.Bool("use-dev-dot-env", false, "Specify if you want to use the .env.dev file")

Expand All @@ -54,12 +56,27 @@ func main() {
return
}

if *onlySeedPinecone {
openAi := search.NewOpenAIClient(config.OpenAISettings)
pinecone := search.NewPineconeClient(openAi, config.PineconeSettings)

err := pinecone.Seed(db)
if err != nil {
fmt.Printf("Error seeding PineconeDB: %s\n", err.Error())
return
}
return
}

err = database.ConnPooling(db)
if err != nil {
Exit("Error with connection pooling: %s", err.Error())
}

app := server.Init(db, *config)
openAi := search.NewOpenAIClient(config.OpenAISettings)
pinecone := search.NewPineconeClient(openAi, config.PineconeSettings)

app := server.Init(db, pinecone, *config)

err = app.Listen(fmt.Sprintf("%s:%d", config.Application.Host, config.Application.Port))
if err != nil {
Expand Down
Loading

0 comments on commit e9ab811

Please sign in to comment.