-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into profile-pages
- Loading branch information
Showing
11 changed files
with
240 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package previews | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/GenerateNU/sac/backend/utilities" | ||
"github.com/garrettladley/fiberpaginate" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
type EventPreviewController struct { | ||
service Service | ||
} | ||
|
||
func NewEventController(service Service) *EventPreviewController { | ||
return &EventPreviewController{service: service} | ||
} | ||
|
||
func (e *EventPreviewController) GetEventPreviews(c *fiber.Ctx) error { | ||
pageInfo, ok := fiberpaginate.FromContext(c) | ||
if !ok { | ||
return utilities.ErrExpectedPageInfo | ||
} | ||
|
||
usePagination := c.QueryBool("pagination", true) | ||
if !usePagination { | ||
pageInfo = nil | ||
} | ||
|
||
events, err := e.service.GetEventPreviews(pageInfo, c.Query("start"), c.Query("end")) | ||
if err != nil { | ||
return err | ||
} | ||
return c.Status(http.StatusOK).JSON(events) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package previews | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/GenerateNU/sac/backend/entities/models" | ||
"github.com/google/uuid" | ||
) | ||
|
||
type common struct { | ||
ID uuid.UUID `json:"id"` | ||
Title string `json:"title"` | ||
EventType models.EventType `json:"event_type"` | ||
Location string `json:"location"` | ||
Link string `json:"link"` | ||
StartTime time.Time `json:"start_time"` | ||
EndTime time.Time `json:"end_time"` | ||
} | ||
|
||
type EventStub struct { | ||
common | ||
Host uuid.UUID `json:"host"` | ||
} | ||
|
||
func (es *EventStub) Into(tags []models.Tag, hostName string, hostLogo string) *EventPreview { | ||
return &EventPreview{ | ||
common: es.common, | ||
Tags: tags, | ||
HostName: hostName, | ||
HostLogo: hostLogo, | ||
} | ||
} | ||
|
||
func (es EventStub) TableName() string { | ||
return "events" | ||
} | ||
|
||
type EventPreview struct { | ||
common | ||
Tags []models.Tag `json:"tags"` | ||
HostName string `json:"host_name"` | ||
HostLogo string `json:"host_logo"` | ||
} |
Oops, something went wrong.