From 1f894622553dfd34c77adf117d258f740c7ddd0d Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Fri, 23 Aug 2024 13:46:33 +0200 Subject: [PATCH] made sure that there is no float vs double vs decimal confusion for lat/lon --- server/backend/migration/20220713000000.go | 12 ++++++------ server/backend/migration/20231015000000.go | 8 ++++---- .../backend/migration/static_data/source-schema.sql | 4 ++-- server/model/cafeteria.go | 4 ++-- server/model/cafeteria_rating_statistic.go | 4 ++-- server/model/dish_rating_statistic.go | 4 ++-- server/model/feedback.go | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/server/backend/migration/20220713000000.go b/server/backend/migration/20220713000000.go index 49d7324c..5bc4bb82 100644 --- a/server/backend/migration/20220713000000.go +++ b/server/backend/migration/20220713000000.go @@ -13,8 +13,8 @@ type InitialCafeteria struct { Cafeteria int64 `gorm:"primary_key;AUTO_INCREMENT;column:cafeteria;type:int;not null;" json:"canteen" ` Name string `gorm:"column:name;type:text;not null;" json:"name" ` Address string `gorm:"column:address;type:text;not null;" json:"address" ` - Latitude float32 `gorm:"column:latitude;type:float;not null;" json:"latitude" ` - Longitude float32 `gorm:"column:longitude;type:float;not null;" json:"longitude"` + Latitude float64 `gorm:"column:latitude;type:double;not null;" json:"latitude" ` + Longitude float64 `gorm:"column:longitude;type:double;not null;" json:"longitude"` } // TableName sets the insert table name for this struct type @@ -186,10 +186,10 @@ func (n *InitialDishToDishNameTag) TableName() string { type InitialCafeteriaRatingAverage struct { CafeteriaRatingAverage int64 `gorm:"primary_key;AUTO_INCREMENT;column:cafeteriaRatingAverage;type:int;not null;" json:"canteenRatingAverage" ` CafeteriaID int64 `gorm:"column:cafeteriaID;foreignKey:cafeteria;type:int;not null;" json:"canteenID"` - Average float64 `gorm:"column:average;type:float;not null;" json:"average" ` + Average float32 `gorm:"column:average;type:float;not null;" json:"average" ` Min int32 `gorm:"column:min;type:int;not null;" json:"min"` Max int32 `gorm:"column:max;type:int;not null;" json:"max"` - Std float64 `gorm:"column:std;type:float;not null;" json:"std"` + Std float32 `gorm:"column:std;type:float;not null;" json:"std"` } // TableName sets the insert table name for this struct type @@ -234,10 +234,10 @@ type InitialDishRatingAverage struct { DishRatingAverage int64 `gorm:"primary_key;AUTO_INCREMENT;column:dishRatingAverage;type:int;not null;" json:"dishRatingAverage" ` CafeteriaID int64 `gorm:"column:cafeteriaID;foreignKey:cafeteria;type:int;not null;" json:"cafeteriaID"` DishID int64 `gorm:"column:dishID;foreignKey:dish;type:int;not null;" json:"dishID"` - Average float64 `gorm:"column:average;type:float;not null;" json:"average" ` + Average float32 `gorm:"column:average;type:float;not null;" json:"average" ` Min int32 `gorm:"column:min;type:int;not null;" json:"min"` Max int32 `gorm:"column:max;type:int;not null;" json:"max"` - Std float64 `gorm:"column:std;type:float;not null;" json:"std"` + Std float32 `gorm:"column:std;type:float;not null;" json:"std"` } // TableName sets the insert table name for this struct type diff --git a/server/backend/migration/20231015000000.go b/server/backend/migration/20231015000000.go index 34a34ca8..c3458b18 100644 --- a/server/backend/migration/20231015000000.go +++ b/server/backend/migration/20231015000000.go @@ -11,10 +11,10 @@ import ( type CafeteriaRatingAverage struct { CafeteriaRatingAverage int64 `gorm:"primary_key;AUTO_INCREMENT;column:cafeteriaRatingAverage;type:int;not null;"` CafeteriaID int64 `gorm:"column:cafeteriaID;foreignKey:cafeteria;type:int;not null;"` - Average float64 `gorm:"column:average;type:float;not null;"` + Average float32 `gorm:"column:average;type:float;not null;"` Min int32 `gorm:"column:min;type:int;not null;"` Max int32 `gorm:"column:max;type:int;not null;"` - Std float64 `gorm:"column:std;type:float;not null;"` + Std float32 `gorm:"column:std;type:float;not null;"` } // TableName sets the insert table name for this struct type @@ -27,10 +27,10 @@ type DishRatingAverage struct { DishRatingAverage int64 `gorm:"primary_key;AUTO_INCREMENT;column:dishRatingAverage;type:int;not null;"` CafeteriaID int64 `gorm:"column:cafeteriaID;foreignKey:cafeteria;type:int;not null;"` DishID int64 `gorm:"column:dishID;foreignKey:dish;type:int;not null;"` - Average float64 `gorm:"column:average;type:float;not null;"` + Average float32 `gorm:"column:average;type:float;not null;"` Min int32 `gorm:"column:min;type:int;not null;"` Max int32 `gorm:"column:max;type:int;not null;"` - Std float64 `gorm:"column:std;type:float;not null;"` + Std float32 `gorm:"column:std;type:float;not null;"` } // TableName sets the insert table name for this struct type diff --git a/server/backend/migration/static_data/source-schema.sql b/server/backend/migration/static_data/source-schema.sql index 575d7493..751779f5 100644 --- a/server/backend/migration/static_data/source-schema.sql +++ b/server/backend/migration/static_data/source-schema.sql @@ -125,8 +125,8 @@ create table if not exists feedback reply_to text charset utf8 null, feedback text charset utf8 not null, image_count int null, - latitude decimal(11, 8) null, - longitude decimal(11, 8) null, + latitude double null, + longitude double null, timestamp datetime /* mariadb-5.3 */ default current_timestamp() null ) auto_increment = 293; diff --git a/server/model/cafeteria.go b/server/model/cafeteria.go index 8387dfb9..3b25eb00 100644 --- a/server/model/cafeteria.go +++ b/server/model/cafeteria.go @@ -5,8 +5,8 @@ type Cafeteria struct { Cafeteria int64 `gorm:"primary_key;AUTO_INCREMENT;column:cafeteria;type:int;not null;" json:"canteen" ` Name string `gorm:"column:name;type:text;not null;" json:"name" ` Address string `gorm:"column:address;type:text;not null;" json:"address" ` - Latitude float32 `gorm:"column:latitude;type:float;not null;" json:"latitude" ` - Longitude float32 `gorm:"column:longitude;type:float;not null;" json:"longitude"` + Latitude float64 `gorm:"column:latitude;type:double;not null;" json:"latitude" ` + Longitude float64 `gorm:"column:longitude;type:double;not null;" json:"longitude"` } // TableName sets the insert table name for this struct type diff --git a/server/model/cafeteria_rating_statistic.go b/server/model/cafeteria_rating_statistic.go index 7af0faeb..56a982b3 100644 --- a/server/model/cafeteria_rating_statistic.go +++ b/server/model/cafeteria_rating_statistic.go @@ -3,8 +3,8 @@ package model // CafeteriaRatingStatistic is a view for statistics of cafeteria ratings type CafeteriaRatingStatistic struct { CafeteriaID int64 `gorm:"column:cafeteriaID;foreignKey:cafeteria;type:int;not null;"` - Average float64 `gorm:"column:average;type:float;not null;"` + Average float32 `gorm:"column:average;type:float;not null;"` Min int32 `gorm:"column:min;type:int;not null;"` Max int32 `gorm:"column:max;type:int;not null;"` - Std float64 `gorm:"column:std;type:float;not null;"` + Std float32 `gorm:"column:std;type:float;not null;"` } diff --git a/server/model/dish_rating_statistic.go b/server/model/dish_rating_statistic.go index bbf56c04..89bfa664 100644 --- a/server/model/dish_rating_statistic.go +++ b/server/model/dish_rating_statistic.go @@ -4,8 +4,8 @@ package model type DishRatingStatistic struct { CafeteriaID int64 `gorm:"column:cafeteriaID;foreignKey:cafeteria;type:int;not null;"` DishID int64 `gorm:"column:dishID;foreignKey:dish;type:int;not null;"` - Average float64 `gorm:"column:average;type:float;not null;"` + Average float32 `gorm:"column:average;type:float;not null;"` Min int32 `gorm:"column:min;type:int;not null;"` Max int32 `gorm:"column:max;type:int;not null;"` - Std float64 `gorm:"column:std;type:float;not null;"` + Std float32 `gorm:"column:std;type:float;not null;"` } diff --git a/server/model/feedback.go b/server/model/feedback.go index 1fd61554..7b036649 100644 --- a/server/model/feedback.go +++ b/server/model/feedback.go @@ -12,8 +12,8 @@ type Feedback struct { ReplyToEmail null.String `gorm:"column:reply_to_email;type:text;null;uniqueIndex:receiver_reply_to_feedback_app_version_uindex,expression:reply_to_email(100)"` ReplyToName null.String `gorm:"column:reply_to_name;type:text;null"` Feedback string `gorm:"column:feedback;type:text;not null;uniqueIndex:receiver_reply_to_feedback_app_version_uindex,expression:feedback(255)"` - Latitude null.Float `gorm:"column:latitude;type:float;null;"` - Longitude null.Float `gorm:"column:longitude;type:float;null;"` + Latitude null.Float `gorm:"column:latitude;type:double;null;"` + Longitude null.Float `gorm:"column:longitude;type:double;null;"` OsVersion null.String `gorm:"column:os_version;type:text;null;"` AppVersion null.String `gorm:"column:app_version;type:text;null;uniqueIndex:receiver_reply_to_feedback_app_version_uindex,expression:app_version(100)"` Processed bool `gorm:"column:processed;type:boolean;default:false;not null;"`