add event list in statistique page

This commit is contained in:
soukainna 2023-02-22 11:01:29 +01:00
parent 97ebcf480e
commit 9965271788
1 changed files with 38 additions and 2 deletions

View File

@ -11,6 +11,8 @@ import (
"time" "time"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting" "git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi" fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
"git.coopgo.io/coopgo-platform/fleets/storage" "git.coopgo.io/coopgo-platform/fleets/storage"
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi" groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
@ -20,6 +22,7 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/timestamppb"
) )
func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) { func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Request) {
@ -64,8 +67,40 @@ func (h *ApplicationHandler) Administration(w http.ResponseWriter, r *http.Reque
} }
sort.Sort(sorting.GroupsByName(groups)) sort.Sort(sorting.GroupsByName(groups))
////////////////////////////////////add event////////////////////////////////////////////
rresp, err := h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
Namespaces: []string{"parcoursmob_dispositifs"},
Mindate: timestamppb.New(time.Now().Add(-24 * time.Hour)),
})
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings) if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
responses := []agendastorage.Event{}
groupids := []string{}
for _, e := range rresp.Events {
groupids = append(groupids, e.Owners...)
responses = append(responses, e.ToStorageType())
}
sort.Sort(sorting.EventsByStartdate(responses))
groupsresp, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
Groupids: groupids,
})
groupps := map[string]any{}
if err == nil {
for _, g := range groupsresp.Groups {
groupps[g.Id] = g.ToStorageType()
}
}
/////////////////////////////////////////////////////////////////////////////////////////
h.Renderer.Administration(w, r, accounts, beneficiaries, groups, bookings, responses)
} }
func (h *ApplicationHandler) AdministrationCreateGroup(w http.ResponseWriter, r *http.Request) { func (h *ApplicationHandler) AdministrationCreateGroup(w http.ResponseWriter, r *http.Request) {
@ -354,7 +389,8 @@ func (h ApplicationHandler) AdminStatVehicles(w http.ResponseWriter, r *http.Req
vehicles, _ := h.services.GetVehiclesMap() vehicles, _ := h.services.GetVehiclesMap()
groups, _ := h.services.GetGroupsMap() groups, _ := h.services.GetGroupsMap()
// fmt.Println(vehicles)
// fmt.Println("////////////////////////////////////////:")
h.Renderer.VehicleBookingsList(w, r, bookings, vehicles, groups) h.Renderer.VehicleBookingsList(w, r, bookings, vehicles, groups)
} }