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
93ee5c02
Commit
93ee5c02
authored
2 years ago
by
Bastien DUMONT
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/dev' into 391-log-loading-times
parents
0e111ba7
6909179b
No related branches found
No related tags found
1 merge request
!884
feat: log loading times
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/migrations/migration.service.ts
+4
-4
4 additions, 4 deletions
src/migrations/migration.service.ts
src/services/initialization.service.ts
+44
-44
44 additions, 44 deletions
src/services/initialization.service.ts
with
48 additions
and
48 deletions
src/migrations/migration.service.ts
+
4
−
4
View file @
93ee5c02
...
...
@@ -15,17 +15,17 @@ import { Migration, MigrationResult } from './migration.type'
export
class
MigrationService
{
private
readonly
_client
:
Client
private
readonly
_set
i
nitStepError
:
React
.
Dispatch
<
private
readonly
_set
I
nitStepError
:
React
.
Dispatch
<
React
.
SetStateAction
<
InitStepsErrors
|
null
>
>
constructor
(
_client
:
Client
,
_set
i
nitStepError
:
React
.
Dispatch
<
_set
I
nitStepError
:
React
.
Dispatch
<
React
.
SetStateAction
<
InitStepsErrors
|
null
>
>
)
{
this
.
_client
=
_client
this
.
_set
i
nitStepError
=
_set
i
nitStepError
this
.
_set
I
nitStepError
=
_set
I
nitStepError
}
/**
* Return schema version
...
...
@@ -74,7 +74,7 @@ export class MigrationService {
const
result
=
await
migrate
(
migration
,
this
.
_client
)
if
(
result
.
type
===
MIGRATION_RESULT_FAILED
)
{
// Error in case of second failure
this
.
_set
i
nitStepError
(
InitStepsErrors
.
MIGRATION_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
MIGRATION_ERROR
)
logApp
.
error
(
migrationLog
(
migration
,
result
))
Sentry
.
captureException
(
migrationLog
(
migration
,
result
))
throw
new
Error
()
...
...
This diff is collapsed.
Click to expand it.
src/services/initialization.service.ts
+
44
−
44
View file @
93ee5c02
...
...
@@ -55,21 +55,21 @@ const logStack = logger.namespace('initializationService')
export
default
class
InitializationService
{
private
readonly
_client
:
Client
private
readonly
_set
i
nitStep
:
React
.
Dispatch
<
React
.
SetStateAction
<
InitSteps
>>
private
readonly
_set
i
nitStepError
:
React
.
Dispatch
<
private
readonly
_set
I
nitStep
:
React
.
Dispatch
<
React
.
SetStateAction
<
InitSteps
>>
private
readonly
_set
I
nitStepError
:
React
.
Dispatch
<
React
.
SetStateAction
<
InitStepsErrors
|
null
>
>
constructor
(
_client
:
Client
,
_set
i
nitStep
:
React
.
Dispatch
<
React
.
SetStateAction
<
InitSteps
>>
,
_set
i
nitStepError
:
React
.
Dispatch
<
_set
I
nitStep
:
React
.
Dispatch
<
React
.
SetStateAction
<
InitSteps
>>
,
_set
I
nitStepError
:
React
.
Dispatch
<
React
.
SetStateAction
<
InitStepsErrors
|
null
>
>
)
{
this
.
_client
=
_client
this
.
_set
i
nitStep
=
_set
i
nitStep
this
.
_set
i
nitStepError
=
_set
i
nitStepError
this
.
_set
I
nitStep
=
_set
I
nitStep
this
.
_set
I
nitStepError
=
_set
I
nitStepError
}
/**
...
...
@@ -82,7 +82,7 @@ export default class InitializationService {
const
startTime
=
performance
.
now
()
const
profileService
=
new
ProfileService
(
this
.
_client
)
try
{
this
.
_set
i
nitStep
(
InitSteps
.
PROFILE
)
this
.
_set
I
nitStep
(
InitSteps
.
PROFILE
)
const
loadedProfile
=
await
profileService
.
getProfile
()
if
(
!
loadedProfile
)
{
// Population with the data
...
...
@@ -93,7 +93,7 @@ export default class InitializationService {
if
(
newProfile
)
{
logDuration
(
'
[Initialization] Profile created
'
,
startTime
)
}
else
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
PROFILE_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
PROFILE_ERROR
)
throw
new
Error
(
'
initProfile: Profile not created
'
)
}
}
...
...
@@ -105,7 +105,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Profile loaded and updated in
'
,
startTime
)
return
updatedProfile
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
PROFILE_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
PROFILE_ERROR
)
const
errorMessage
=
`Initialization error - initProfile: :
${
JSON
.
stringify
(
error
...
...
@@ -131,7 +131,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] ProfileType loaded
'
,
startTime
)
return
loadedProfileType
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
PROFILETYPE_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
PROFILETYPE_ERROR
)
const
errorMessage
=
`Initialization error - initProfileType:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -150,7 +150,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] ProfileEcogesture loaded
'
,
startTime
)
return
loadedProfileEcogesture
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
PROFILETYPE_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
PROFILETYPE_ERROR
)
const
errorMessage
=
`Initialization error - initProfileEcogesture:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -163,7 +163,7 @@ export default class InitializationService {
public
async
initEcogesture
(
hash
:
string
):
Promise
<
string
>
{
const
startTime
=
performance
.
now
()
this
.
_set
i
nitStep
(
InitSteps
.
ECOGESTURE
)
this
.
_set
I
nitStep
(
InitSteps
.
ECOGESTURE
)
const
hashEcogestureType
=
hashFile
(
ecogestureData
)
const
ecogestureService
=
new
EcogestureService
(
this
.
_client
)
// Populate data if none ecogesture exists
...
...
@@ -180,7 +180,7 @@ export default class InitializationService {
// Check of created document based on count
const
checkCount
=
await
ecogestureService
.
getAllEcogestures
()
if
(
!
checkCount
||
checkCount
?.
length
!==
ecogestureData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
ECOGESTURE_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
ECOGESTURE_ERROR
)
throw
new
Error
(
'
initEcogesture: Created ecogesture type entities does not match
'
)
...
...
@@ -188,7 +188,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Ecogesture list created
'
,
startTime
)
return
hashEcogestureType
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
ECOGESTURE_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
ECOGESTURE_ERROR
)
const
errorMessage
=
`Initialization error - initEcogesture:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -221,7 +221,7 @@ export default class InitializationService {
// Check of created document based on count
const
checkCount
=
await
ecogestureService
.
getAllEcogestures
()
if
(
!
checkCount
||
checkCount
?.
length
!==
ecogestureData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
ECOGESTURE_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
ECOGESTURE_ERROR
)
throw
new
Error
(
'
initEcogesture: Created ecogesture type entities does not match
'
)
...
...
@@ -229,7 +229,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Ecogesture updated
'
,
startTime
)
return
hashEcogestureType
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
ECOGESTURE_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
ECOGESTURE_ERROR
)
const
errorMessage
=
`Initialization error - initEcogesture:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -291,7 +291,7 @@ export default class InitializationService {
public
async
initChallengeEntity
(
hash
:
string
):
Promise
<
string
>
{
const
startTime
=
performance
.
now
()
this
.
_set
i
nitStep
(
InitSteps
.
CHALLENGES
)
this
.
_set
I
nitStep
(
InitSteps
.
CHALLENGES
)
const
challengeHash
=
hashFile
(
challengeEntityData
)
const
challengeService
=
new
ChallengeService
(
this
.
_client
)
// Populate data if none challengeEntity exists
...
...
@@ -306,7 +306,7 @@ export default class InitializationService {
// Check of created document
const
checkCount
=
await
challengeService
.
getAllChallengeEntities
()
if
(
!
checkCount
||
checkCount
?.
length
!==
challengeEntityData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initChallengeEntity: Created challenge entities does not match
'
)
...
...
@@ -314,7 +314,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Challenge entities created
'
,
startTime
)
return
challengeHash
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initChallengeEntity:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -337,7 +337,7 @@ export default class InitializationService {
// Check of created document
const
checkCount
=
await
challengeService
.
getAllChallengeEntities
()
if
(
!
checkCount
||
checkCount
?.
length
!==
challengeEntityData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initChallengeEntity: Created challenge entities does not match
'
)
...
...
@@ -345,7 +345,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Challenge entities updated
'
,
startTime
)
return
challengeHash
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initChallengeEntity:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -376,7 +376,7 @@ export default class InitializationService {
// Check of created document
const
checkCount
=
await
duelService
.
getAllDuelEntities
()
if
(
!
checkCount
||
checkCount
?.
length
!==
duelEntityData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initDuelEntity: Created duel entities does not match
'
)
...
...
@@ -384,7 +384,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] UserDuel entities created
'
,
startTime
)
return
hashDuelEntity
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initDuelEntity:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -407,7 +407,7 @@ export default class InitializationService {
// Check of created document
const
checkCount
=
await
duelService
.
getAllDuelEntities
()
if
(
!
checkCount
||
checkCount
?.
length
!==
duelEntityData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initDuelEntity: Created duel entities does not match
'
)
...
...
@@ -415,7 +415,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] UserDuel entities updated
'
,
startTime
)
return
hashDuelEntity
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initDuelEntity:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -446,7 +446,7 @@ export default class InitializationService {
// Check of created document
const
checkCount
=
await
quizService
.
getAllQuizEntities
()
if
(
!
checkCount
||
checkCount
?.
length
!==
quizEntityData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initQuizEntity: Created quiz entities does not match
'
)
...
...
@@ -455,7 +455,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Quiz entities created
'
,
startTime
)
return
quizHash
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initQuizEntity:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -478,7 +478,7 @@ export default class InitializationService {
// Check of created document
const
checkCount
=
await
quizService
.
getAllQuizEntities
()
if
(
!
checkCount
||
checkCount
?.
length
!==
quizEntityData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initQuizEntity: Created quiz entities does not match
'
)
...
...
@@ -486,7 +486,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Quiz entities updated
'
,
startTime
)
return
quizHash
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initQuizEntity:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -521,7 +521,7 @@ export default class InitializationService {
!
checkCount
||
checkCount
?.
length
!==
explorationEntityData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initExplorationEntity: Created exploration entities does not match
'
)
...
...
@@ -529,7 +529,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Exploration entities created
'
,
startTime
)
return
explorationHash
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initExplorationEntity:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -555,7 +555,7 @@ export default class InitializationService {
!
checkCount
||
checkCount
?.
length
!==
explorationEntityData
.
length
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initExplorationEntity: Created exploration entities does not match
'
)
...
...
@@ -563,7 +563,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Exploration entities updated
'
,
startTime
)
return
explorationHash
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initExplorationEntity:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -609,7 +609,7 @@ export default class InitializationService {
}
}
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
ANALYSIS_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
ANALYSIS_ERROR
)
const
errorMessage
=
`Initialization error - initAnalysis:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -634,11 +634,11 @@ export default class InitializationService {
logDuration
(
'
[Initialization] Fluid Types loaded
'
,
startTime
)
return
fluidtypes
}
else
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CONSOS_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CONSOS_ERROR
)
throw
new
Error
(
'
initFluidTypes: FluidTypes not found
'
)
}
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CONSOS_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CONSOS_ERROR
)
logApp
.
error
(
'
Initialization error - :
'
,
error
)
const
errorMessage
=
`Initialization error - initFluidTypes:
${
JSON
.
stringify
(
error
...
...
@@ -659,17 +659,17 @@ export default class InitializationService {
const
startTime
=
performance
.
now
()
const
fs
=
new
FluidService
(
this
.
_client
)
try
{
this
.
_set
i
nitStep
(
InitSteps
.
CONSOS
)
this
.
_set
I
nitStep
(
InitSteps
.
CONSOS
)
const
fluidStatus
=
await
fs
.
getFluidStatus
()
if
(
fluidStatus
)
{
logDuration
(
'
[Initialization] Fluid Status loaded
'
,
startTime
)
return
fluidStatus
}
else
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CONSOS_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CONSOS_ERROR
)
throw
new
Error
(
'
initFluidStatus: fluidStatus not found
'
)
}
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CONSOS_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CONSOS_ERROR
)
const
errorMessage
=
`Initialization error - initFluidStatus:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -698,11 +698,11 @@ export default class InitializationService {
logDuration
(
'
[Initialization] initUserChallenges
'
,
startTime
)
return
userChallengeList
}
else
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
throw
new
Error
(
'
initUserChallenges: userChallengeList not found
'
)
}
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - initUserChallenges:
${
JSON
.
stringify
(
error
)}
`
...
...
@@ -730,7 +730,7 @@ export default class InitializationService {
logDuration
(
'
[Initialization] initDuelProgress finished
'
,
startTime
)
return
{
updatedUserChallenge
,
dataloads
}
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CHALLENGES_ERROR
)
const
errorMessage
=
`Initialization error - :
${
JSON
.
stringify
(
error
)}
`
logStack
(
'
error
'
,
errorMessage
)
logApp
.
error
(
errorMessage
)
...
...
@@ -746,7 +746,7 @@ export default class InitializationService {
}
const
startTime
=
performance
.
now
()
try
{
this
.
_set
i
nitStep
(
InitSteps
.
CONSENT
)
this
.
_set
I
nitStep
(
InitSteps
.
CONSENT
)
const
termService
=
new
TermsService
(
this
.
_client
)
const
isUpToDate
=
await
termService
.
isConsentVersionUpToDate
()
const
lastTerm
=
await
termService
.
getLastTerm
()
...
...
@@ -785,7 +785,7 @@ export default class InitializationService {
return
termsStatus
}
catch
(
error
)
{
this
.
_set
i
nitStepError
(
InitStepsErrors
.
CONSENT_ERROR
)
this
.
_set
I
nitStepError
(
InitStepsErrors
.
CONSENT_ERROR
)
const
errorMessage
=
`Initialization error - initConsent:
${
JSON
.
stringify
(
error
)}
`
...
...
This diff is collapsed.
Click to expand it.
Hugo NOUTS
@hnouts
mentioned in commit
6614789f
·
2 years ago
mentioned in commit
6614789f
mentioned in commit 6614789fcc53a1b06f8cb8883ff2efa87a0decb8
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