Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore:Chat removal #195

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions server/backend/cron/chat.go

This file was deleted.

3 changes: 0 additions & 3 deletions server/backend/cron/cronjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const (
IOSActivityReset = "iosActivityReset"

/* MensaType = "mensa"
ChatType = "chat"
KinoType = "kino"
RoomfinderType = "roomfinder"
AlarmType = "alarm" */
Expand Down Expand Up @@ -107,8 +106,6 @@ func (c *CronService) Run() error {
TODO: Implement handlers for other cronjobs
case MensaType:
g.Go(func() error { return c.mensaCron() })
case ChatType:
g.Go(func() error { return c.chatCron() })
case KinoType:
g.Go(func() error { return c.kinoCron() })
case RoomfinderType:
Expand Down
25 changes: 25 additions & 0 deletions server/backend/migration/20230825000000.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package migration

import (
"github.com/TUM-Dev/Campus-Backend/server/model"
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)

// migrate20230825000000
// Removes the ability to run chat cronjobs
func (m TumDBMigrator) migrate20230825000000() *gormigrate.Migration {
return &gormigrate.Migration{
ID: "20230825000000",
Migrate: func(tx *gorm.DB) error {
// deactivete the crontab (Rollback deletes this from the enum)
// given that previously, not cronjobs for this type existed there is no need to remove offending entries first
return SafeEnumRollback(tx, &model.Crontab{}, "type", "chat")
},
Rollback: func(tx *gorm.DB) error {
// activete the crontab (Migrate adds this from to the enum)
// given that previously, not cronjobs for this type existed there is no need to add entries first
return SafeEnumMigrate(tx, &model.Crontab{}, "type", "chat")
},
}
}
1 change: 1 addition & 0 deletions server/backend/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (m TumDBMigrator) Migrate() error {
m.migrate20221119131300(),
m.migrate20221210000000(),
m.migrate20230904000000(),
m.migrate20230825000000(),
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
})
err := mig.Migrate()
return err
Expand Down
2 changes: 1 addition & 1 deletion server/model/crontab.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Crontab struct {
//[ 2] lastRun int null: false primary: false isArray: false auto: false col: int len: -1 default: [0]
LastRun int32 `gorm:"column:lastRun;type:int;default:0;" json:"last_run"`
//[ 3] type char(10) null: true primary: false isArray: false auto: false col: char len: 10 default: []
Type null.String `gorm:"column:type;type:enum ('news', 'mensa', 'chat', 'kino', 'roomfinder', 'alarm', 'fileDownload','dishNameDownload','averageRatingComputation', 'iosNotifications', 'iosActivityReset', 'canteenHeadCount');" json:"type"`
Type null.String `gorm:"column:type;type:enum ('news', 'mensa', 'kino', 'roomfinder', 'alarm', 'fileDownload','dishNameDownload','averageRatingComputation', 'iosNotifications', 'iosActivityReset', 'canteenHeadCount');" json:"type"`
//[ 4] id int null: true primary: false isArray: false auto: false col: int len: -1 default: []
ID null.Int `gorm:"column:id;type:int;" json:"id"`
}
Loading