lot of new functionalities

This commit is contained in:
Arnaud Delcasse
2025-10-14 18:11:13 +02:00
parent a6f70a6e85
commit d992a7984f
164 changed files with 15113 additions and 9442 deletions

View File

@@ -1,55 +0,0 @@
package services
import (
"context"
// "time"
diags "git.coopgo.io/coopgo-platform/diags/grpcapi"
"git.coopgo.io/coopgo-platform/diags/storage"
"google.golang.org/grpc"
// "google.golang.org/protobuf/types/known/timestamppb"
)
type DiagsService struct {
diags.DiagsClient
}
func NewDiagsService(dial string) (*DiagsService, error) {
conn, err := grpc.Dial(dial, grpc.WithInsecure())
client := diags.NewDiagsClient(conn)
if err != nil {
return nil, err
}
return &DiagsService{
DiagsClient: client,
}, nil
}
func (s *ServicesHandler) GetDiagsDiags() ([]DiagsDiag, error) {
resp, err := s.GRPC.Diags.GetDiags(context.TODO(), &diags.GetDiagsRequest{
Namespaces: []string{"parcoursmob_beneficiaires", "parcoursmob_diagnostiques"},
})
if err != nil {
return nil, err
}
diags := []DiagsDiag{}
for _, e := range resp.Diags {
newDiag := DiagsDiag{
Diag: e.ToStorageType(),
}
diags = append(diags, newDiag)
}
return diags, nil
}
// Enriched types
type DiagsDiag struct {
OwnersGroups []GroupsManagementGroup
storage.Diag
}

View File

@@ -4,7 +4,7 @@ import (
"context"
"sort"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
"git.coopgo.io/coopgo-apps/parcoursmob/core/utils/sorting"
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
"git.coopgo.io/coopgo-platform/fleets/storage"
"github.com/rs/zerolog/log"

View File

@@ -3,6 +3,7 @@ package services
import (
"context"
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
"git.coopgo.io/coopgo-platform/mobility-accounts/storage"
"google.golang.org/grpc"
@@ -134,3 +135,27 @@ func (s *ServicesHandler) GetAccount(id string) (account storage.Account, err er
return resp.Account.ToStorageType(), nil
}
func (s *ServicesHandler) GetBeneficiariesInGroup(group groupstorage.Group) (accounts []storage.Account, err error) {
accounts = []storage.Account{}
if len(group.Members) == 0 {
return accounts, nil
}
request := &mobilityaccounts.GetAccountsBatchRequest{
Accountids: group.Members,
}
resp, err := s.GRPC.MobilityAccounts.GetAccountsBatch(context.TODO(), request)
if err != nil {
return accounts, err
}
for _, account := range resp.Accounts {
a := account.ToStorageType()
accounts = append(accounts, a)
}
return accounts, nil
}

23
services/savedsearch.go Normal file
View File

@@ -0,0 +1,23 @@
package services
import (
"git.coopgo.io/coopgo-platform/saved-search/servers/grpc/proto/gen"
"google.golang.org/grpc"
)
type SavedSearchService struct {
gen.SavedSearchServiceClient
}
func NewSavedSearchService(dial string) (*SavedSearchService, error) {
conn, err := grpc.Dial(dial, grpc.WithInsecure())
client := gen.NewSavedSearchServiceClient(conn)
if err != nil {
return nil, err
}
return &SavedSearchService{
SavedSearchServiceClient: client,
}, nil
}

View File

@@ -3,7 +3,6 @@ package services
import (
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
carpoolservice "git.coopgo.io/coopgo-platform/carpool-service/servers/grpc/proto"
diags "git.coopgo.io/coopgo-platform/diags/grpcapi"
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
"git.coopgo.io/coopgo-platform/geography/handlers/admin"
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
@@ -12,6 +11,7 @@ import (
"git.coopgo.io/coopgo-platform/multimodal-routing/libs/transit/transitous"
"git.coopgo.io/coopgo-platform/payments/pricing"
"git.coopgo.io/coopgo-platform/routing-service"
savedsearch "git.coopgo.io/coopgo-platform/saved-search/servers/grpc/proto/gen"
"git.coopgo.io/coopgo-platform/sms"
solidaritytransport "git.coopgo.io/coopgo-platform/solidarity-transport/servers/grpc/proto/gen"
"github.com/rs/zerolog/log"
@@ -35,7 +35,7 @@ type GRPCServices struct {
Agenda agenda.AgendaClient
SolidarityTransport solidaritytransport.SolidarityTransportClient
CarpoolService carpoolservice.CarpoolServiceClient
Diags diags.DiagsClient
SavedSearch savedsearch.SavedSearchServiceClient
}
func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
@@ -46,10 +46,10 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
agendaDial = cfg.GetString("services.grpc.agenda.dial")
solidarityTransportDial = cfg.GetString("services.grpc.solidaritytransport.dial")
carpoolServiceDial = cfg.GetString("services.grpc.carpoolservice.dial")
savedSearchDial = cfg.GetString("services.grpc.savedsearch.dial")
routing_service_type = cfg.GetString("routing.type")
valhalla_base_url = cfg.GetString("routing.valhalla.base_url")
// diagsDial = cfg.GetString("services.grpc.diags.dial")
)
mobilityAccounts, err := NewMobilityAccountService(mobilityAccountsDial)
if err != nil {
@@ -86,11 +86,12 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
return nil, err
}
//diagsSvc, err := NewDiagsService(diagsDial)
// log.Error().Err(err).Msg("Mobility Accounts service issue")
//if err != nil {
// return nil, err
//}
savedSearchSvc, err := NewSavedSearchService(savedSearchDial)
if err != nil {
log.Error().Err(err).Msg("Saved Search service issue")
return nil, err
}
routing, err := routing.NewRoutingService(routing_service_type, valhalla_base_url)
if err != nil {
log.Fatal().Err(err).Msg("Could not initiate the routing service")
@@ -135,7 +136,7 @@ func NewServicesHandler(cfg *viper.Viper) (*ServicesHandler, error) {
Agenda: agendaSvc,
SolidarityTransport: solidarityTransportSvc,
CarpoolService: carpoolSvc,
// Diags: diagsSvc,
SavedSearch: savedSearchSvc,
},
Routing: routing,
InteropCarpool: carpoolRouting,