Skip to content

Commit

Permalink
fixed datatypes for the tagnames
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasjungmann committed Oct 3, 2023
1 parent 8941fba commit 8562a74
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions server/backend/cafeteria_rating_db_initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ func updateNameTagOptions(db *gorm.DB) {
log.WithError(res.Error).WithFields(fields).Error("Unable to load tag")
}
if res.RowsAffected == 0 || res.Error != nil {
parent := model.DishRatingTagOption{
parent := model.DishNameTagOption{
DE: v.TagNameGerman,
EN: v.TagNameEnglish,
}

if err := db.Model(&model.DishNameTagOption{}).Create(&parent).Error; err != nil {
log.WithError(err).WithFields(fields).Error("Error while creating tag")
}
parentId = parent.DishRatingTagOption
parentId = parent.DishNameTagOption
}

addCanBeIncluded(parentId, db, v)
Expand Down Expand Up @@ -176,11 +176,21 @@ func updateTagTable(path string, db *gorm.DB, tagType modelType) {
}

if count == 0 {
element := model.DishRatingTagOption{
DE: v.TagNameGerman,
EN: v.TagNameEnglish,
var createError error
if tagType == CAFETERIA {
element := model.CafeteriaRatingTagOption{
DE: v.TagNameGerman,
EN: v.TagNameEnglish,
}
createError = insertModel.Create(&element).Error
} else {
element := model.DishRatingTagOption{
DE: v.TagNameGerman,
EN: v.TagNameEnglish,
}
createError = insertModel.Create(&element).Error
}
createError := insertModel.Create(&element).Error

if createError != nil {
log.WithError(createError).WithFields(fields).Error("Unable to create new can be excluded tag")
} else {
Expand Down

0 comments on commit 8562a74

Please sign in to comment.