fleetmap-reports 1.0.732 → 1.0.734

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": "fleetmap-reports",
3
- "version": "1.0.732",
3
+ "version": "1.0.734",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -2,6 +2,7 @@ const { getReports } = require('./index')
2
2
  const assert = require('assert')
3
3
  // eslint-disable-next-line no-undef
4
4
  describe('zones', function () {
5
+ this.timeout(500000)
5
6
  // eslint-disable-next-line no-undef
6
7
  it('works with ellca', async () => {
7
8
  const report = await getReports()
@@ -21,7 +22,7 @@ describe('zones', function () {
21
22
 
22
23
  // eslint-disable-next-line no-undef
23
24
  it('works with afriquia', async () => {
24
- const report = await getReports('moviflotte@gmail.com', 'moviflotte@gmail.com')
25
+ const report = await getReports(process.env.USER_AFRIQUIA, process.env.PASS_AFRIQUIA)
25
26
  const userData = await report.getUserData()
26
27
  console.log(userData.devices.length)
27
28
  console.log(userData.geofences)
@@ -34,7 +35,7 @@ describe('zones', function () {
34
35
 
35
36
  // eslint-disable-next-line no-undef
36
37
  it('works with casais', async () => {
37
- const report = await getReports('mario.andre.moreira@casais.gi', 'Casais.23')
38
+ const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
38
39
  const userData = await report.getUserData()
39
40
  userData.devices = userData.devices.filter(d => d.name === 'G-1101-E Clio')
40
41
  userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ')
@@ -58,13 +59,12 @@ describe('zones', function () {
58
59
  assert.equal(userData.geofences.length > 0, true)
59
60
  assert.equal(userData.devices.length > 0, true)
60
61
  const result = await report.zoneReport(
61
- new Date(Date.UTC(2023, 1, 27, 0, 0, 0, 0)),
62
- new Date(Date.UTC(2023, 1, 27, 23, 59, 59, 0)),
62
+ new Date(2023, 1, 27, 0, 0, 0, 0),
63
+ new Date(2023, 1, 27, 23, 59, 59, 0),
63
64
  userData)
64
65
  assert.equal(result[0].devices[0].geofences.length, 1)
65
66
  assert.equal(result[0].devices[0].geofences[0].days.length, 1)
66
67
  const first = result[0].devices[0].geofences[0].days[0]
67
- console.log(first)
68
68
  assert.equal(first.firstIn, '2023-02-27T21:53:16.000+0000')
69
69
  assert.equal(first.distanceIn, 93.03917199839687)
70
70
  assert.equal(first.distanceOut, 819.6685737216337)
package/src/util/utils.js CHANGED
@@ -106,9 +106,13 @@ function convertToFeature (geofence) {
106
106
  }
107
107
  }
108
108
 
109
- function getDates (startDate, endDate) {
109
+ function getDates (startDate, endDate, timezone) {
110
110
  const dates = []
111
111
  let currentDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(), 12, 0, 0, 0)
112
+ if (!isClientSide() && timezone) {
113
+ const startDateUserTimezone = convertFromUTC(startDate, timezone)
114
+ currentDate = new Date(startDateUserTimezone.getFullYear(), startDateUserTimezone.getMonth(), startDateUserTimezone.getDate(), 12, 0, 0, 0)
115
+ }
112
116
  const addDays = function (days) {
113
117
  const date = new Date(this.valueOf())
114
118
  date.setDate(date.getDate() + days)
@@ -99,7 +99,7 @@ async function processDevices (from, to, devices, userData, data) {
99
99
  const zoneInOutData = analyseAlerts(alerts, deviceRoute, userData, from, to).filter(d => !userData.onlyWithStop || d.stopped)
100
100
 
101
101
  if (userData.groupByDay) {
102
- const dates = getDates(from, to)
102
+ const dates = getDates(from, to, userData.user.attributes.timezone)
103
103
 
104
104
  const geofencesData = []
105
105
  for (const geofence of userData.geofences) {