diff --git a/grpcapi/grpcapi.go b/grpcapi/grpcapi.go index 6938c09..6a5ea86 100644 --- a/grpcapi/grpcapi.go +++ b/grpcapi/grpcapi.go @@ -55,7 +55,8 @@ func (s FleetsServerImpl) GetVehicle(ctx context.Context, req *GetVehicleRequest func (s FleetsServerImpl) GetVehicles(ctx context.Context, req *GetVehiclesRequest) (*GetVehiclesResponse, error) { filter := storage.VehicleFilters{ - Types: req.Types, + Types: req.Types, + Administrators: req.Administrators, } if req.AvailabilityFrom.IsValid() { filter.AvailableFrom = req.AvailabilityFrom.AsTime() diff --git a/main.go b/main.go index 9527b9a..2ca8d12 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ func main() { var ( service_name = cfg.GetString("name") grpc_enable = cfg.GetBool("services.grpc.enable") + dev_env = cfg.GetBool("dev_env") ) storage, err := storage.NewStorage(cfg) @@ -28,6 +29,9 @@ func main() { handler := handlers.NewHandler(cfg, storage) fmt.Println("Running", service_name, ":") + if dev_env { + fmt.Printf("\033]0;%s\007", service_name) + } failed := make(chan error) diff --git a/storage/vehicles.go b/storage/vehicles.go index fd9c525..e4da167 100644 --- a/storage/vehicles.go +++ b/storage/vehicles.go @@ -17,9 +17,10 @@ type Vehicle struct { } type VehicleFilters struct { - Types []string - AvailableFrom time.Time - AvailableTo time.Time + Types []string + Administrators []string + AvailableFrom time.Time + AvailableTo time.Time } func (v Vehicle) Free(start time.Time, end time.Time) bool { @@ -49,6 +50,21 @@ func (v Vehicle) MatchesFilters(filters VehicleFilters) bool { } } + if len(filters.Administrators) > 0 { + found := false + for _, a := range filters.Administrators { + for _, va := range v.Administrators { + if a == va { + found = true + break + } + } + } + if !found { + return false + } + } + if !v.Free(filters.AvailableFrom, filters.AvailableTo) { return false }