Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ecolyo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
Ecolyo
Commits
d728db57
Commit
d728db57
authored
9 months ago
by
Bastien DUMONT
Browse files
Options
Downloads
Plain Diff
Merge branch 'chore/remove-get-old-fluid' into 'dev'
chore: remove unused getOldFluidData See merge request
!1232
parents
cc891a7b
fc55a98f
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!1241
3.1 Release
,
!1232
chore: remove unused getOldFluidData
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/services/fluid.service.spec.ts
+0
-141
0 additions, 141 deletions
src/services/fluid.service.spec.ts
src/services/fluid.service.ts
+0
-27
0 additions, 27 deletions
src/services/fluid.service.ts
with
0 additions
and
168 deletions
src/services/fluid.service.spec.ts
+
0
−
141
View file @
d728db57
...
...
@@ -529,145 +529,4 @@ describe('Fluid service', () => {
expect
(
fluidStatus
[
2
].
maintenance
).
toBeTruthy
()
})
})
describe
(
'
getOldFluidData method
'
,
()
=>
{
it
(
'
should return Electricity as old fluid
'
,
async
()
=>
{
const
mockFluidStatus
:
FluidStatus
[]
=
[
{
fluidType
:
FluidType
.
ELECTRICITY
,
status
:
FluidState
.
DONE
,
maintenance
:
false
,
firstDataDate
:
DateTime
.
fromISO
(
'
2019-01-01
'
).
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
}),
lastDataDate
:
DateTime
.
fromISO
(
'
2020-01-01
'
).
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
}),
connection
:
{
konnector
:
konnectorsData
[
0
],
account
:
accountsData
[
0
],
trigger
:
triggersData
[
0
],
triggerState
:
triggerStateData
,
shouldLaunchKonnector
:
false
,
isUpdating
:
false
,
konnectorConfig
:
{
name
:
'
Enedis
'
,
oauth
:
false
,
slug
:
FluidSlugType
.
ELECTRICITY
,
siteLink
:
'
https://mon-compte-client.enedis.fr/
'
,
activation
:
'
https://mon-compte-particulier.enedis.fr/donnees/
'
,
},
},
},
]
const
result
=
await
FluidService
.
getOldFluidData
(
mockFluidStatus
)
expect
(
result
).
toEqual
([
FluidType
.
ELECTRICITY
])
})
it
(
'
should return empty array as lastdatadate < 5 days
'
,
async
()
=>
{
const
mockFluidStatus
:
FluidStatus
[]
=
[
{
fluidType
:
FluidType
.
ELECTRICITY
,
status
:
FluidState
.
DONE
,
maintenance
:
false
,
firstDataDate
:
DateTime
.
local
().
minus
({
day
:
31
}).
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
}),
lastDataDate
:
DateTime
.
local
().
minus
({
day
:
1
}).
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
}),
connection
:
{
konnector
:
konnectorsData
[
0
],
account
:
accountsData
[
0
],
trigger
:
triggersData
[
0
],
triggerState
:
triggerStateData
,
shouldLaunchKonnector
:
false
,
isUpdating
:
false
,
konnectorConfig
:
{
name
:
'
Enedis
'
,
oauth
:
false
,
slug
:
FluidSlugType
.
ELECTRICITY
,
siteLink
:
'
https://mon-compte-client.enedis.fr/
'
,
activation
:
'
https://mon-compte-particulier.enedis.fr/donnees/
'
,
},
},
},
]
const
result
=
await
FluidService
.
getOldFluidData
(
mockFluidStatus
)
expect
(
result
).
toEqual
([])
})
it
(
'
should return empty array as status is NOT_CONNECTED
'
,
async
()
=>
{
const
mockFluidStatus
:
FluidStatus
[]
=
[
{
fluidType
:
FluidType
.
ELECTRICITY
,
status
:
FluidState
.
NOT_CONNECTED
,
maintenance
:
false
,
firstDataDate
:
DateTime
.
fromISO
(
'
2019-01-01
'
).
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
}),
lastDataDate
:
DateTime
.
fromISO
(
'
2020-01-01
'
).
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
}),
connection
:
{
konnector
:
konnectorsData
[
0
],
account
:
accountsData
[
0
],
trigger
:
triggersData
[
0
],
triggerState
:
triggerStateData
,
shouldLaunchKonnector
:
false
,
isUpdating
:
false
,
konnectorConfig
:
{
name
:
'
Enedis
'
,
oauth
:
false
,
slug
:
FluidSlugType
.
ELECTRICITY
,
siteLink
:
'
https://mon-compte-client.enedis.fr/
'
,
activation
:
'
https://mon-compte-particulier.enedis.fr/donnees/
'
,
},
},
},
]
const
result
:
FluidType
[]
=
await
FluidService
.
getOldFluidData
(
mockFluidStatus
)
expect
(
result
).
toEqual
([])
})
it
(
'
should return empty array as status is KONNECTOR_NOT_FOUND
'
,
async
()
=>
{
const
mockFluidStatus
:
FluidStatus
[]
=
[
{
fluidType
:
FluidType
.
ELECTRICITY
,
status
:
FluidState
.
KONNECTOR_NOT_FOUND
,
maintenance
:
false
,
firstDataDate
:
DateTime
.
fromISO
(
'
2019-01-01
'
).
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
}),
lastDataDate
:
DateTime
.
fromISO
(
'
2020-01-01
'
).
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
}),
connection
:
{
konnector
:
konnectorsData
[
0
],
account
:
accountsData
[
0
],
trigger
:
triggersData
[
0
],
triggerState
:
triggerStateData
,
shouldLaunchKonnector
:
false
,
isUpdating
:
false
,
konnectorConfig
:
{
name
:
'
Enedis
'
,
oauth
:
false
,
slug
:
FluidSlugType
.
ELECTRICITY
,
siteLink
:
'
https://mon-compte-client.enedis.fr/
'
,
activation
:
'
https://mon-compte-particulier.enedis.fr/donnees/
'
,
},
},
},
]
const
result
:
FluidType
[]
=
await
FluidService
.
getOldFluidData
(
mockFluidStatus
)
expect
(
result
).
toEqual
([])
})
it
(
'
should return empty array
'
,
async
()
=>
{
const
result
:
FluidType
[]
=
await
FluidService
.
getOldFluidData
([])
expect
(
result
).
toEqual
([])
})
})
})
This diff is collapsed.
Click to expand it.
src/services/fluid.service.ts
+
0
−
27
View file @
d728db57
...
...
@@ -157,31 +157,4 @@ export default class FluidService {
]
return
result
}
/**
* Return fluids with data older than 5 days
*/
static
getOldFluidData
=
async
(
fluidStatus
:
FluidStatus
[]
):
Promise
<
FluidType
[]
>
=>
{
const
fluidOldData
:
FluidType
[]
=
[]
if
(
fluidStatus
.
length
>
0
)
{
for
(
const
fluid
of
fluidStatus
)
{
let
diffInDays
=
0
if
(
fluid
?.
lastDataDate
)
{
const
dateToCompare
=
fluid
.
lastDataDate
diffInDays
=
dateToCompare
.
diffNow
(
'
days
'
).
toObject
().
days
||
0
if
(
diffInDays
<
-
5
&&
fluid
.
status
!==
FluidState
.
KONNECTOR_NOT_FOUND
&&
fluid
.
status
!==
FluidState
.
NOT_CONNECTED
)
{
!
fluidOldData
.
includes
(
fluid
.
fluidType
)
&&
fluidOldData
.
push
(
fluid
.
fluidType
)
}
}
}
}
return
fluidOldData
}
}
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in commit
9d9d6670
·
9 months ago
mentioned in commit
9d9d6670
mentioned in commit 9d9d66706ca5bfc00849ee9d3cf671e84aebb5ad
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment