mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 06:22:40 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75bb82094d | ||
|
|
8d2964659b | ||
|
|
8eb1b51457 | ||
|
|
a1ff6f9f45 | ||
|
|
c09b1b9863 | ||
|
|
337c28370d | ||
|
|
14c43afb34 | ||
|
|
73ed3a948e | ||
|
|
b0718e83df | ||
|
|
4547dcf655 | ||
|
|
c5e58db5a6 | ||
|
|
d4412a0cf1 | ||
|
|
5ca5200f1a | ||
|
|
62e4015ea7 | ||
|
|
c3e03e179c | ||
|
|
07e44a259b |
@@ -4,6 +4,10 @@ stages:
|
|||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
|
|
||||||
|
include:
|
||||||
|
- template: Security/SAST.gitlab-ci.yml
|
||||||
|
- template: Security/Secret-Detection.gitlab-ci.yml
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# TEST STAGE #
|
# TEST STAGE #
|
||||||
##############
|
##############
|
||||||
|
|||||||
@@ -181,7 +181,6 @@ If the matching is successful, you will get a result, containing :
|
|||||||
- **page**: the number of the page that is returned (may be different than the number of the required page, if number of results does not match with perPage parameter)
|
- **page**: the number of the page that is returned (may be different than the number of the required page, if number of results does not match with perPage parameter)
|
||||||
- **perPage**: the number of results per page (as it may not be specified in the request)
|
- **perPage**: the number of results per page (as it may not be specified in the request)
|
||||||
- **data**: an array of the results themselves, each including:
|
- **data**: an array of the results themselves, each including:
|
||||||
- **id**: an id for the result
|
|
||||||
- **adId**: the id of the ad that matches
|
- **adId**: the id of the ad that matches
|
||||||
- **role**: the role of the ad owner in that match
|
- **role**: the role of the ad owner in that match
|
||||||
- **distance**: the distance in metres of the resulting carpool
|
- **distance**: the distance in metres of the resulting carpool
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@mobicoop/matcher",
|
"name": "@mobicoop/matcher",
|
||||||
"version": "1.3.0",
|
"version": "1.4.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@mobicoop/matcher",
|
"name": "@mobicoop/matcher",
|
||||||
"version": "1.3.0",
|
"version": "1.4.1",
|
||||||
"license": "AGPL",
|
"license": "AGPL",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.9.9",
|
"@grpc/grpc-js": "^1.9.9",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mobicoop/matcher",
|
"name": "@mobicoop/matcher",
|
||||||
"version": "1.3.0",
|
"version": "1.4.1",
|
||||||
"description": "Mobicoop V3 Matcher",
|
"description": "Mobicoop V3 Matcher",
|
||||||
"author": "sbriat",
|
"author": "sbriat",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@@ -38,24 +38,22 @@ export class Journey extends ValueObject<JourneyProps> {
|
|||||||
actorTime.target == Target.START,
|
actorTime.target == Target.START,
|
||||||
) as ActorTime,
|
) as ActorTime,
|
||||||
) as JourneyItem;
|
) as JourneyItem;
|
||||||
const passengerDepartureActorTime =
|
const passengerDepartureActorTime: ActorTime =
|
||||||
passengerDepartureJourneyItem.actorTimes.find(
|
passengerDepartureJourneyItem.actorTimes.find(
|
||||||
(actorTime: ActorTime) =>
|
(actorTime: ActorTime) =>
|
||||||
actorTime.role == Role.PASSENGER && actorTime.target == Target.START,
|
actorTime.role == Role.PASSENGER && actorTime.target == Target.START,
|
||||||
) as ActorTime;
|
) as ActorTime;
|
||||||
const driverNeutralActorTime =
|
const driverActorTime = passengerDepartureJourneyItem.actorTimes.find(
|
||||||
passengerDepartureJourneyItem.actorTimes.find(
|
(actorTime: ActorTime) => actorTime.role == Role.DRIVER,
|
||||||
(actorTime: ActorTime) =>
|
|
||||||
actorTime.role == Role.DRIVER && actorTime.target == Target.NEUTRAL,
|
|
||||||
) as ActorTime;
|
) as ActorTime;
|
||||||
return (
|
return (
|
||||||
(passengerDepartureActorTime.firstMinDatetime <=
|
(passengerDepartureActorTime.firstMinDatetime <=
|
||||||
driverNeutralActorTime.firstMaxDatetime &&
|
driverActorTime.firstMaxDatetime &&
|
||||||
driverNeutralActorTime.firstMaxDatetime <=
|
driverActorTime.firstMaxDatetime <=
|
||||||
passengerDepartureActorTime.firstMaxDatetime) ||
|
passengerDepartureActorTime.firstMaxDatetime) ||
|
||||||
(passengerDepartureActorTime.firstMinDatetime <=
|
(passengerDepartureActorTime.firstMinDatetime <=
|
||||||
driverNeutralActorTime.firstMinDatetime &&
|
driverActorTime.firstMinDatetime &&
|
||||||
driverNeutralActorTime.firstMinDatetime <=
|
driverActorTime.firstMinDatetime <=
|
||||||
passengerDepartureActorTime.firstMaxDatetime)
|
passengerDepartureActorTime.firstMaxDatetime)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,18 +57,17 @@ enum AlgorithmType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message Match {
|
message Match {
|
||||||
string id = 1;
|
string adId = 1;
|
||||||
string adId = 2;
|
string role = 2;
|
||||||
string role = 3;
|
int32 distance = 3;
|
||||||
int32 distance = 4;
|
int32 duration = 4;
|
||||||
int32 duration = 5;
|
int32 initialDistance = 5;
|
||||||
int32 initialDistance = 6;
|
int32 initialDuration = 6;
|
||||||
int32 initialDuration = 7;
|
int32 distanceDetour = 7;
|
||||||
int32 distanceDetour = 8;
|
int32 durationDetour = 8;
|
||||||
int32 durationDetour = 9;
|
double distanceDetourPercentage = 9;
|
||||||
double distanceDetourPercentage = 10;
|
double durationDetourPercentage = 10;
|
||||||
double durationDetourPercentage = 11;
|
repeated Journey journeys = 11;
|
||||||
repeated Journey journeys = 12;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message Journey {
|
message Journey {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ const mockAdRepository: AdRepositoryPort = {
|
|||||||
insertExtra: jest.fn(),
|
insertExtra: jest.fn(),
|
||||||
findOneById: jest.fn(),
|
findOneById: jest.fn(),
|
||||||
findOne: jest.fn(),
|
findOne: jest.fn(),
|
||||||
|
findAll: jest.fn(),
|
||||||
insert: jest.fn(),
|
insert: jest.fn(),
|
||||||
update: jest.fn(),
|
update: jest.fn(),
|
||||||
updateWhere: jest.fn(),
|
updateWhere: jest.fn(),
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ const mockMatcherRepository: AdRepositoryPort = {
|
|||||||
insertExtra: jest.fn(),
|
insertExtra: jest.fn(),
|
||||||
findOneById: jest.fn(),
|
findOneById: jest.fn(),
|
||||||
findOne: jest.fn(),
|
findOne: jest.fn(),
|
||||||
|
findAll: jest.fn(),
|
||||||
insert: jest.fn(),
|
insert: jest.fn(),
|
||||||
update: jest.fn(),
|
update: jest.fn(),
|
||||||
updateWhere: jest.fn(),
|
updateWhere: jest.fn(),
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ const mockMatcherRepository: AdRepositoryPort = {
|
|||||||
insertExtra: jest.fn(),
|
insertExtra: jest.fn(),
|
||||||
findOneById: jest.fn(),
|
findOneById: jest.fn(),
|
||||||
findOne: jest.fn(),
|
findOne: jest.fn(),
|
||||||
|
findAll: jest.fn(),
|
||||||
insert: jest.fn(),
|
insert: jest.fn(),
|
||||||
update: jest.fn(),
|
update: jest.fn(),
|
||||||
updateWhere: jest.fn(),
|
updateWhere: jest.fn(),
|
||||||
|
|||||||
@@ -195,8 +195,15 @@ const mockMatchMapper = {
|
|||||||
frequency: 'RECURRENT',
|
frequency: 'RECURRENT',
|
||||||
distance: 356041,
|
distance: 356041,
|
||||||
duration: 12647,
|
duration: 12647,
|
||||||
|
initialDistance: 349251,
|
||||||
|
initialDuration: 12103,
|
||||||
|
distanceDetour: 6790,
|
||||||
|
durationDetour: 544,
|
||||||
|
distanceDetourPercentage: 4.1,
|
||||||
|
durationDetourPercentage: 3.8,
|
||||||
journeys: [
|
journeys: [
|
||||||
{
|
{
|
||||||
|
day: 5,
|
||||||
firstDate: '2023-09-01',
|
firstDate: '2023-09-01',
|
||||||
lastDate: '2024-08-30',
|
lastDate: '2024-08-30',
|
||||||
journeyItems: [
|
journeyItems: [
|
||||||
@@ -205,16 +212,11 @@ const mockMatchMapper = {
|
|||||||
lon: 6.17651,
|
lon: 6.17651,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
distance: 0,
|
distance: 0,
|
||||||
|
time: '07:00',
|
||||||
actorTimes: [
|
actorTimes: [
|
||||||
{
|
{
|
||||||
role: 'DRIVER',
|
role: 'DRIVER',
|
||||||
target: 'START',
|
target: 'START',
|
||||||
firstDatetime: '2023-09-01 07:00',
|
|
||||||
firstMinDatetime: '2023-09-01 06:45',
|
|
||||||
firstMaxDatetime: '2023-09-01 07:15',
|
|
||||||
lastDatetime: '2024-08-30 07:00',
|
|
||||||
lastMinDatetime: '2024-08-30 06:45',
|
|
||||||
lastMaxDatetime: '2024-08-30 07:15',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -223,26 +225,15 @@ const mockMatchMapper = {
|
|||||||
lon: 6.67487,
|
lon: 6.67487,
|
||||||
duration: 2100,
|
duration: 2100,
|
||||||
distance: 56878,
|
distance: 56878,
|
||||||
|
time: '07:35',
|
||||||
actorTimes: [
|
actorTimes: [
|
||||||
{
|
{
|
||||||
role: 'DRIVER',
|
role: 'DRIVER',
|
||||||
target: 'NEUTRAL',
|
target: 'NEUTRAL',
|
||||||
firstDatetime: '2023-09-01 07:35',
|
|
||||||
firstMinDatetime: '2023-09-01 07:20',
|
|
||||||
firstMaxDatetime: '2023-09-01 07:50',
|
|
||||||
lastDatetime: '2024-08-30 07:35',
|
|
||||||
lastMinDatetime: '2024-08-30 07:20',
|
|
||||||
lastMaxDatetime: '2024-08-30 07:50',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'PASSENGER',
|
role: 'PASSENGER',
|
||||||
target: 'START',
|
target: 'START',
|
||||||
firstDatetime: '2023-09-01 07:32',
|
|
||||||
firstMinDatetime: '2023-09-01 07:17',
|
|
||||||
firstMaxDatetime: '2023-09-01 07:47',
|
|
||||||
lastDatetime: '2024-08-30 07:32',
|
|
||||||
lastMinDatetime: '2024-08-30 07:17',
|
|
||||||
lastMaxDatetime: '2024-08-30 07:47',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -251,26 +242,15 @@ const mockMatchMapper = {
|
|||||||
lon: 6.9427,
|
lon: 6.9427,
|
||||||
duration: 3840,
|
duration: 3840,
|
||||||
distance: 76491,
|
distance: 76491,
|
||||||
|
time: '08:04',
|
||||||
actorTimes: [
|
actorTimes: [
|
||||||
{
|
{
|
||||||
role: 'DRIVER',
|
role: 'DRIVER',
|
||||||
target: 'NEUTRAL',
|
target: 'NEUTRAL',
|
||||||
firstDatetime: '2023-09-01 08:04',
|
|
||||||
firstMinDatetime: '2023-09-01 07:51',
|
|
||||||
firstMaxDatetime: '2023-09-01 08:19',
|
|
||||||
lastDatetime: '2024-08-30 08:04',
|
|
||||||
lastMinDatetime: '2024-08-30 07:51',
|
|
||||||
lastMaxDatetime: '2024-08-30 08:19',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'PASSENGER',
|
role: 'PASSENGER',
|
||||||
target: 'FINISH',
|
target: 'FINISH',
|
||||||
firstDatetime: '2023-09-01 08:01',
|
|
||||||
firstMinDatetime: '2023-09-01 07:46',
|
|
||||||
firstMaxDatetime: '2023-09-01 08:16',
|
|
||||||
lastDatetime: '2024-08-30 08:01',
|
|
||||||
lastMinDatetime: '2024-08-30 07:46',
|
|
||||||
lastMaxDatetime: '2024-08-30 08:16',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -279,16 +259,11 @@ const mockMatchMapper = {
|
|||||||
lon: 7.02154,
|
lon: 7.02154,
|
||||||
duration: 4980,
|
duration: 4980,
|
||||||
distance: 96475,
|
distance: 96475,
|
||||||
|
time: '08:23',
|
||||||
actorTimes: [
|
actorTimes: [
|
||||||
{
|
{
|
||||||
role: 'DRIVER',
|
role: 'DRIVER',
|
||||||
target: 'FINISH',
|
target: 'FINISH',
|
||||||
firstDatetime: '2023-09-01 08:23',
|
|
||||||
firstMinDatetime: '2023-09-01 08:08',
|
|
||||||
firstMaxDatetime: '2023-09-01 08:38',
|
|
||||||
lastDatetime: '2024-08-30 08:23',
|
|
||||||
lastMinDatetime: '2024-08-30 08:08',
|
|
||||||
lastMaxDatetime: '2024-08-30 08:38',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user