add fuel subtype to fillup

This commit is contained in:
Akhil Gupta
2021-07-23 16:30:55 +05:30
parent 19ab2a59dd
commit 4ee44fb1f1
10 changed files with 69 additions and 2 deletions

View File

@@ -139,6 +139,7 @@ func CreateFillup(model models.CreateFillupRequest) (*db.Fillup, error) {
Date: model.Date,
Currency: user.Currency,
DistanceUnit: user.DistanceUnit,
FuelSubType: model.FuelSubType,
Source: "API",
}
@@ -196,6 +197,7 @@ func UpdateFillup(fillupId string, model models.UpdateFillupRequest) error {
Comments: model.Comments,
FillingStation: model.FillingStation,
UserID: model.UserID,
FuelSubType: model.FuelSubType,
Date: model.Date,
}).Error
}
@@ -235,6 +237,11 @@ func GetVehicleAttachments(vehicleId string) (*[]db.Attachment, error) {
return db.GetVehicleAttachments(vehicleId)
}
func GetDistinctFuelSubtypesForVehicle(vehicleId string) ([]string, error) {
var names []string
tx := db.DB.Model(&db.Fillup{}).Where("vehicle_id=? and fuel_sub_type is not null", vehicleId).Distinct().Pluck("fuel_sub_type", &names)
return names, tx.Error
}
func GetUserStats(userId string, model models.UserStatsQueryModel) ([]models.VehicleStatsModel, error) {