Skip to content

Commit

Permalink
Merge pull request vacaramin#79 from vacaramin/Notifications
Browse files Browse the repository at this point in the history
Migration Script updated
  • Loading branch information
vacaramin authored Dec 10, 2023
2 parents 1df5b46 + d7be982 commit 7f141fa
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
20 changes: 17 additions & 3 deletions backend/Migrations/001_initial.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,29 @@ VALUES
);

INSERT INTO
notifications (user_id, message,status)
notifications (user_id, message, status)
VALUES
(
2,
'Welcome to Virtual Horizon, Thank you for signing up',
'Welcome to Virtual Horizon, Thank you for signing up',
'unread'
),
(
2,
'Welcome Again, Thank you for signing up',
'Welcome Again, Thank you for signing up',
'unread'
);

INSERT INTO
notifications (user_id, message, status)
VALUES
(
1,
'Welcome to Virtual Horizon, Thank you for signing up',
'unread'
),
(
1,
'Please Join meeting for MCAT Class',
'unread'
);
1 change: 1 addition & 0 deletions backend/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func SetupRoutes(r *gin.Engine) {
studentController := &studentcontrollers.StudentController{}
tutorController := &tutorControllers.TutorController{}
notificationController := &notificationControllers.NotificationController{}

// user routes are being set in this route function
courseRoutes.SetupRoutes(r, courseController)
enrollmentRoutes.SetupRoutes(r, enrollmentController)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type NotificationFunctions interface {
GetNotifications(*gin.Context)
}

func (_ *NotificationController) GetNotifications(ctx *gin.Context) {
func (*NotificationController) GetNotifications(ctx *gin.Context) {

user, err := utils.GetUserFromToken(ctx)
if err != nil {
Expand All @@ -28,6 +28,7 @@ func (_ *NotificationController) GetNotifications(ctx *gin.Context) {

initializers.DB.
Where("user_id = ?", user.ID).
//Order("created_at DESC").
Find(&Notifications)

ctx.JSON(http.StatusOK, gin.H{
Expand Down
6 changes: 3 additions & 3 deletions backend/src/notifications/routes/notifications.routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gin-gonic/gin"
)

func SetupRoutes(engine *gin.Engine, controller controllers.NotificationFunctions) {
enrollmentRoutes := engine.Group("notification")
enrollmentRoutes.POST("getNotifications", controller.GetNotifications)
func SetupRoutes(r *gin.Engine, controller controllers.NotificationFunctions) {
enrollmentRoutes := r.Group("notification")
enrollmentRoutes.GET("getnotifications", controller.GetNotifications)
}
2 changes: 1 addition & 1 deletion docker-compose-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ services:
# vh-net:
# ipv4_address: 172.19.0.6
volumes:
db-data:
db-data:

0 comments on commit 7f141fa

Please sign in to comment.