@autofleet/node-common 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/node-common",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "coverage": "jest --coverage --forceExit --runInBand",
package/settings/map.js CHANGED
@@ -86,6 +86,13 @@ module.exports = {
86
86
  defaultValue: 15000,
87
87
  context: 'matching',
88
88
  },
89
+ MATCHING_MINIMUM_PAID_RATIO: {
90
+ name: 'Matching min paid/unpaid air distance',
91
+ description: 'The ratio between paid to unpaid air distance - pre filter',
92
+ type: 'number',
93
+ defaultValue: 0.1,
94
+ context: 'matching',
95
+ },
89
96
  ETA_MAX: {
90
97
  name: 'Maximum time to pickup',
91
98
  description: 'The maximum allowed time to pickup in matching',
@@ -135,6 +142,13 @@ module.exports = {
135
142
  defaultValue: 0,
136
143
  context: 'placement',
137
144
  },
145
+ NUMBER_OF_TASKS_CLUSTERS_PER_PLACEMENTS: {
146
+ name: 'Number of clusters for driver tasks',
147
+ description: 'Will be max by the number of movements',
148
+ type: 'number',
149
+ defaultValue: 5,
150
+ context: 'placement',
151
+ },
138
152
  VAAS_PLACEMENT_VEHICLE_RIDE_RATIO: {
139
153
  name: 'VAAS placement vehicle - ride ratio',
140
154
  description: 'The ratio between vehicle and ride for RAAS placement',
package/events/example.js DELETED
@@ -1,20 +0,0 @@
1
- const event = require('./index');
2
-
3
- const vehicleEvent = {
4
- event_timestamp: '2018-08-10 11:05:11',
5
- vehicle_id: '1a',
6
- fleet_id: '2b',
7
- shift_id: '3c',
8
- action: 'Changed State',
9
- original_state: 'Activating',
10
- new_state: 'Idle',
11
- lat: 5.7,
12
- lng: 8.9,
13
- city_name: 'Tel Aviv',
14
- region_name: 'Hamerkaz',
15
- country_name: 'Israel',
16
- duration: 1420,
17
- additional_params: '{}',
18
- };
19
-
20
- event.publish('vehicle', vehicleEvent, true);
package/events/index.js DELETED
@@ -1,78 +0,0 @@
1
- const PubSub = require('@google-cloud/pubsub');
2
- const logger = require('../logger/index')();
3
-
4
- let Client;
5
- let Publisher;
6
-
7
- const getPubsubPublisher = async () => {
8
- if (Publisher) {
9
- return Publisher;
10
- }
11
-
12
- const envv = process.env.NODE_ENV || 'development';
13
- const projectId = process.env.PROJECT;
14
- const topic = process.env.TOPIC;
15
-
16
- if (!topic || !projectId) {
17
- return {
18
- debug: 'Missing project/topic',
19
- };
20
- }
21
-
22
- if ((envv === 'development' || envv === 'test')) {
23
- return {
24
- debug: 'Not publishing in dev/test',
25
- };
26
- }
27
-
28
- Client = new PubSub({ projectId });
29
- Publisher = Client.topic(topic).publisher();
30
-
31
- return {
32
- client: Client,
33
- publisher: Publisher,
34
- topic,
35
- envv,
36
- };
37
- };
38
-
39
- // EventType - 'vehicle'/'stop_point' etc.
40
- const publish = (eventType, eventObj) => {
41
- const {
42
- debug,
43
- publisher,
44
- envv,
45
- } = getPubsubPublisher();
46
-
47
- if (debug) {
48
- return debug;
49
- }
50
-
51
- const msg = {
52
- type: eventType,
53
- event: eventObj,
54
- env: envv,
55
- };
56
-
57
- const data = JSON.stringify(msg);
58
- const dataBuffer = Buffer.from(data);
59
-
60
- return publisher
61
- .publish(dataBuffer)
62
- .then((messageId) => {
63
- logger.info(`Message ${messageId} published to google pubsub`);
64
- })
65
- .catch((err) => {
66
- logger.error('Error when try to publish to pubsub:', { error: err ? err.message : err });
67
- });
68
- };
69
-
70
- const publishRideAnalytics = (eventObject) => {
71
- try {
72
- publish('rideAnalytics', eventObject);
73
- } catch (err) {
74
- logger.error('Error when try to send ride analytics:', { error: err ? err.message : err });
75
- }
76
- };
77
-
78
- module.exports = { publish, publishRideAnalytics };