From 84cfe0db117b33b48777aee1fc963e6ddb075d39 Mon Sep 17 00:00:00 2001
From: hnouts <hnouts@grandlyon.com>
Date: Tue, 2 May 2023 16:38:17 +0200
Subject: [PATCH] publish: Merge remote-tracking branch 'origin/dev' into
 391-skip-migrations

generated from commit c00b6f8ea66aa473730885f91478faaffd58b04b
---
 ...adcd.js => ecolyo.2bf120e617b7bfcd9d25.js} | 85 +++++++++++--------
 index.html                                    |  2 +-
 2 files changed, 51 insertions(+), 36 deletions(-)
 rename app/{ecolyo.11572c55abdfe5beadcd.js => ecolyo.2bf120e617b7bfcd9d25.js} (99%)

diff --git a/app/ecolyo.11572c55abdfe5beadcd.js b/app/ecolyo.2bf120e617b7bfcd9d25.js
similarity index 99%
rename from app/ecolyo.11572c55abdfe5beadcd.js
rename to app/ecolyo.2bf120e617b7bfcd9d25.js
index 6ff191813..164687c70 100644
--- a/app/ecolyo.11572c55abdfe5beadcd.js
+++ b/app/ecolyo.2bf120e617b7bfcd9d25.js
@@ -1895,7 +1895,7 @@ var SplashRoot = function SplashRoot(_ref) {
 
     function _loadData() {
       _loadData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
-        var initializationService, customPopupService, partnersInfoService, ms, startTime, transaction, migrationsResult, termsStatus, profile, profileType, profileEcogesture, _yield$Promise$all, _yield$Promise$all2, ecogestureHash, duelHash, quizHash, challengeHash, explorationHash, analysisResult, updatedProfile, fluidStatus, refDate, lastDataDate, _iterator, _step, fluid, userChallengeList, _filteredCurrentOngoi, _filteredCurrentOngoi2, _filteredCurrentOngoi3, _filteredCurrentDuelC, filteredCurrentOngoingChallenge, actionService, updatedUserChallenge, filteredCurrentDuelChallenge, _yield$initialization, _updatedUserChallenge, dataloads, challengeService, _yield$challengeServi, isDone;
+        var initializationService, customPopupService, partnersInfoService, ms, startTime, transaction, termsStatus, profile, profileType, profileEcogesture, migrationsResult, _yield$Promise$all, _yield$Promise$all2, ecogestureHash, duelHash, quizHash, challengeHash, explorationHash, analysisResult, updatedProfile, fluidStatus, refDate, lastDataDate, _iterator, _step, fluid, userChallengeList, _filteredCurrentOngoi, _filteredCurrentOngoi2, _filteredCurrentOngoi3, _filteredCurrentDuelC, filteredCurrentOngoingChallenge, actionService, updatedUserChallenge, filteredCurrentDuelChallenge, _yield$initialization, _updatedUserChallenge, dataloads, challengeService, _yield$challengeServi, isDone;
 
         return _regenerator.default.wrap(function _callee6$(_context6) {
           while (1) {
@@ -1911,39 +1911,38 @@ var SplashRoot = function SplashRoot(_ref) {
                 });
                 _context6.prev = 6;
                 _context6.next = 9;
-                return ms.runMigrations(_migration.migrations);
-
-              case 9:
-                migrationsResult = _context6.sent;
-                // Init last release notes when they exist
-                dispatch((0, _global.showReleaseNotes)(migrationsResult.show, migrationsResult.notes, migrationsResult.redirectLink)); // init Terms
-
-                _context6.next = 13;
                 return initializationService.initConsent();
 
-              case 13:
+              case 9:
                 termsStatus = _context6.sent;
                 if (subscribed) dispatch((0, _global.updateTermValidation)(termsStatus)); // Init fluidPrices
 
-                _context6.next = 17;
+                _context6.next = 13;
                 return initializationService.initFluidPrices();
 
-              case 17:
-                _context6.next = 19;
+              case 13:
+                _context6.next = 15;
                 return initializationService.initProfile();
 
-              case 19:
+              case 15:
                 profile = _context6.sent;
-                _context6.next = 22;
+                _context6.next = 18;
                 return initializationService.initProfileType();
 
-              case 22:
+              case 18:
                 profileType = _context6.sent;
-                _context6.next = 25;
+                _context6.next = 21;
                 return initializationService.initProfileEcogesture();
 
-              case 25:
+              case 21:
                 profileEcogesture = _context6.sent;
+                _context6.next = 24;
+                return ms.runMigrations(_migration.migrations);
+
+              case 24:
+                migrationsResult = _context6.sent;
+                // Init last release notes when they exist
+                dispatch((0, _global.showReleaseNotes)(migrationsResult.show, migrationsResult.notes, migrationsResult.redirectLink));
 
                 if (!(subscribed && profile)) {
                   _context6.next = 43;
@@ -31304,6 +31303,7 @@ var _interopRequireDefault = __webpack_require__("TqRt");
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
+exports.initSchemaDoctype = void 0;
 exports.migrate = migrate;
 exports.migrationLog = migrationLog;
 
@@ -31580,18 +31580,22 @@ var schemaExist = /*#__PURE__*/function () {
 
 var initSchemaDoctype = /*#__PURE__*/function () {
   var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_client) {
+    var targetVersion,
+        _args2 = arguments;
     return _regenerator.default.wrap(function _callee2$(_context2) {
       while (1) {
         switch (_context2.prev = _context2.next) {
           case 0:
-            _logger.default.info('[Migration] Init doctype');
+            targetVersion = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : _migration.SCHEMA_INITIAL_VERSION;
 
-            _context2.next = 3;
+            _logger.default.info("[Migration] Init schema doctype to version ".concat(targetVersion));
+
+            _context2.next = 4;
             return _client.create(_comGrandlyonEcolyoSchemas.SCHEMAS_DOCTYPE, {
-              version: _migration.SCHEMA_INITIAL_VERSION
+              version: targetVersion
             });
 
-          case 3:
+          case 4:
           case "end":
             return _context2.stop();
         }
@@ -31611,6 +31615,8 @@ var initSchemaDoctype = /*#__PURE__*/function () {
  */
 
 
+exports.initSchemaDoctype = initSchemaDoctype;
+
 function migrate(_x11, _x12) {
   return _migrate.apply(this, arguments);
 }
@@ -38146,6 +38152,10 @@ var _fluid = __webpack_require__("5Wkc");
 
 var _luxon = __webpack_require__("ExVU");
 
+var _migration = __webpack_require__("mfVY");
+
+var _migration2 = __webpack_require__("6QIQ");
+
 var _initialisationSteps = __webpack_require__("3HG6");
 
 var _challenge = _interopRequireDefault(__webpack_require__("kdea"));
@@ -38210,7 +38220,7 @@ var InitializationService = /*#__PURE__*/function () {
   }
   /**
    * Check if profil exist
-   * If not, the profil is created
+   * If not, the profil is created and migrations are set to latest
    * success return: profil
    * failure return: null
    */
@@ -38239,7 +38249,7 @@ var InitializationService = /*#__PURE__*/function () {
                 loadedProfile = _context.sent;
 
                 if (loadedProfile) {
-                  _context.next = 18;
+                  _context.next = 20;
                   break;
                 }
 
@@ -38251,34 +38261,39 @@ var InitializationService = /*#__PURE__*/function () {
                 newProfile = _yield$this$_client$c.data;
 
                 if (!newProfile) {
-                  _context.next = 16;
+                  _context.next = 18;
                   break;
                 }
 
-                (0, _duration.logDuration)('[Initialization] Profile created', startTime);
-                _context.next = 18;
-                break;
+                (0, _duration.logDuration)('[Initialization] Profile created', startTime); // create schema to latest version
+
+                _context.next = 16;
+                return (0, _migration.initSchemaDoctype)(this._client, _migration2.migrations.length);
 
               case 16:
+                _context.next = 20;
+                break;
+
+              case 18:
                 this._setInitStepError(_initialisationSteps.InitStepsErrors.PROFILE_ERROR);
 
                 throw new Error('initProfile: Profile not created');
 
-              case 18:
-                _context.next = 20;
+              case 20:
+                _context.next = 22;
                 return profileService.updateProfile({
                   lastConnectionDate: _luxon.DateTime.local().setZone('utc', {
                     keepLocalTime: true
                   })
                 });
 
-              case 20:
+              case 22:
                 updatedProfile = _context.sent;
                 (0, _duration.logDuration)('[Initialization] Profile loaded and updated in', startTime);
                 return _context.abrupt("return", updatedProfile);
 
-              case 25:
-                _context.prev = 25;
+              case 27:
+                _context.prev = 27;
                 _context.t0 = _context["catch"](2);
 
                 this._setInitStepError(_initialisationSteps.InitStepsErrors.PROFILE_ERROR);
@@ -38291,12 +38306,12 @@ var InitializationService = /*#__PURE__*/function () {
                 Sentry.captureException(errorMessage);
                 throw _context.t0;
 
-              case 33:
+              case 35:
               case "end":
                 return _context.stop();
             }
           }
-        }, _callee, this, [[2, 25]]);
+        }, _callee, this, [[2, 27]]);
       }));
 
       function initProfile() {
diff --git a/index.html b/index.html
index 248b5b4df..ff723cf42 100644
--- a/index.html
+++ b/index.html
@@ -1 +1 @@
-<!DOCTYPE html><html lang="{{.Locale}}"><head><meta charset="utf-8"><title>Ecolyo</title><link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16"><!-- PWA Manifest --><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#297EF2"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,viewport-fit=cover"><!-- PWA Chrome --><link rel="icon" sizes="192x192" href="/android-chrome-192x192.png"><link rel="icon" sizes="512x512" href="/android-chrome-512x512.png"><!-- PWA iOS --><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="apple-touch-startup-image" href="/apple-touch-icon.png"><meta name="apple-mobile-web-app-title" content="Ecolyo"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><!-- PWA Colors --><meta name="theme-color" content="#343641"><meta name="background-color" content="#121212">{{.ThemeCSS}} {{.CozyBar}}<script src="//{{.Domain}}/assets/js/piwik.js"></script></head><body><div role="application" class="application" data-cozy="{{.CozyData}}"><script src="vendors/ecolyo.18c101a0fa585f93c419.js"></script><script src="app/ecolyo.11572c55abdfe5beadcd.js"></script></div></body></html>
\ No newline at end of file
+<!DOCTYPE html><html lang="{{.Locale}}"><head><meta charset="utf-8"><title>Ecolyo</title><link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16"><!-- PWA Manifest --><link rel="manifest" href="/manifest.json" crossorigin="use-credentials"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#297EF2"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,viewport-fit=cover"><!-- PWA Chrome --><link rel="icon" sizes="192x192" href="/android-chrome-192x192.png"><link rel="icon" sizes="512x512" href="/android-chrome-512x512.png"><!-- PWA iOS --><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="apple-touch-startup-image" href="/apple-touch-icon.png"><meta name="apple-mobile-web-app-title" content="Ecolyo"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><!-- PWA Colors --><meta name="theme-color" content="#343641"><meta name="background-color" content="#121212">{{.ThemeCSS}} {{.CozyBar}}<script src="//{{.Domain}}/assets/js/piwik.js"></script></head><body><div role="application" class="application" data-cozy="{{.CozyData}}"><script src="vendors/ecolyo.18c101a0fa585f93c419.js"></script><script src="app/ecolyo.2bf120e617b7bfcd9d25.js"></script></div></body></html>
\ No newline at end of file
-- 
GitLab