Attached Files | issue36662.diff [^] (4,610 bytes) 2017-09-04 15:38 [Show Content] [Hide Content]# HG changeset patch
# User Antonio Moreno <antonio.moreno@openbravo.com>
# Date 1503927040 -7200
# Mon Aug 28 15:30:40 2017 +0200
# Node ID 169b54b67af843f6f202430504cfcb69b91cce5b
# Parent 443b0a0eb45eeca9e03efe0080f6632ad046c624
Fixed issue 36662. Localdb will be forcefully refreshed after masterdata refresh has been done.
The problem reported by the customer seems to be related to the fact that the local database files are not cached initially by the operating system/browser, which means that the first search is very slow. Subsequent searches are then very fast, because after this initial query, the file is already cached.
The solution is to force the refresh and caching of the local database files after the masterdata models have been refreshed. To do this a simple query is executed for all models right after the loadModels function has finished.
diff -r 443b0a0eb45e -r 169b54b67af8 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Wed Aug 23 13:58:21 2017 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Mon Aug 28 15:30:40 2017 +0200
@@ -831,6 +831,18 @@
<!--6149E342C65048CE91979580BED5714E--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--6149E342C65048CE91979580BED5714E--></AD_MESSAGE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--><AD_MESSAGE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <AD_MESSAGE_ID><![CDATA[61CB4F9E6C7E4680B3EDD6D63D83CBF1]]></AD_MESSAGE_ID>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <VALUE><![CDATA[OBMOBC_ForcingRefreshOfLocalDatabase]]></VALUE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <MSGTEXT><![CDATA[Forcing refresh of local database]]></MSGTEXT>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <AD_MODULE_ID><![CDATA[08943B85ADF64E708797A753E5B6AAEE]]></AD_MODULE_ID>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--></AD_MESSAGE>
+
<!--6281AFF0B9134AA3AE8AADEA64F833D6--><AD_MESSAGE>
<!--6281AFF0B9134AA3AE8AADEA64F833D6--> <AD_MESSAGE_ID><![CDATA[6281AFF0B9134AA3AE8AADEA64F833D6]]></AD_MESSAGE_ID>
<!--6281AFF0B9134AA3AE8AADEA64F833D6--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 443b0a0eb45e -r 169b54b67af8 web/org.openbravo.mobile.core/source/data/ob-dal.js
--- a/web/org.openbravo.mobile.core/source/data/ob-dal.js Wed Aug 23 13:58:21 2017 +0200
+++ b/web/org.openbravo.mobile.core/source/data/ob-dal.js Mon Aug 28 15:30:40 2017 +0200
@@ -1497,6 +1497,22 @@
OB.Dal.loadModels = function (online, models, data, incremental) {
var timestamp = 0;
+ var modelsInLocalDb = [];
+
+ function forceLocalDatabaseLoad(models, idx, callback) {
+ if (idx === models.length) {
+ if (callback) {
+ callback();
+ }
+ return;
+ }
+
+ OB.Dal.find(models[idx], {}, function () {
+ forceLocalDatabaseLoad(models, idx + 1, callback);
+ }, function () {
+ forceLocalDatabaseLoad(models, idx + 1, callback);
+ });
+ }
function triggerReady(models) {
if (incremental && models._LoadQueue && OB.UTIL.queueStatus(models._LoadQueue)) {
@@ -1516,7 +1532,11 @@
// If we are performing a full refresh of the data, now we can set the POSLastTotalRefresh timestamp.
OB.UTIL.localStorage.setItem('POSLastTotalRefresh', new Date().getTime());
}
- models.trigger('ready');
+ OB.UTIL.showLoadingMessage(OB.I18N.getLabel('OBMOBC_ForcingRefreshOfLocalDatabase'));
+ forceLocalDatabaseLoad(modelsInLocalDb, 0, function () {
+ models.trigger('ready');
+ });
+
} else {
// We know that the load of one or more models have failed.
// Reload the page to load all the models again.
@@ -1583,6 +1603,7 @@
if (incremental && OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName)) {
timestamp = OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName);
}
+ modelsInLocalDb.push(item);
OB.UTIL.localStorage.removeItem('recordsFromBackendFor' + item.prototype.modelName);
ds = new OB.DS.DataSource(new OB.DS.Request(item, timestamp));
models._failedModels = models._failedModels || [];
issue36662-2.diff [^] (1,576 bytes) 2017-09-04 15:38 [Show Content] [Hide Content]# HG changeset patch
# User Antonio Moreno <antonio.moreno@openbravo.com>
# Date 1504004013 -7200
# Tue Aug 29 12:53:33 2017 +0200
# Node ID d060f32d8896bacee6f3d7d666b6494ac4d5a6dc
# Parent b90f916bbbd69e2ed37eef7f98a11f6e94e26932
Related to issue 36662. Added limit to avoid problems if model doesn't define a limit by default. Only refresh offline models.
diff -r b90f916bbbd6 -r d060f32d8896 web/org.openbravo.mobile.core/source/data/ob-dal.js
--- a/web/org.openbravo.mobile.core/source/data/ob-dal.js Mon Aug 28 15:30:40 2017 +0200
+++ b/web/org.openbravo.mobile.core/source/data/ob-dal.js Tue Aug 29 12:53:33 2017 +0200
@@ -1507,7 +1507,9 @@
return;
}
- OB.Dal.find(models[idx], {}, function () {
+ OB.Dal.find(models[idx], {
+ _limit: 100
+ }, function () {
forceLocalDatabaseLoad(models, idx + 1, callback);
}, function () {
forceLocalDatabaseLoad(models, idx + 1, callback);
@@ -1603,7 +1605,9 @@
if (incremental && OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName)) {
timestamp = OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName);
}
- modelsInLocalDb.push(item);
+ if (!item.prototype.online) {
+ modelsInLocalDb.push(item);
+ }
OB.UTIL.localStorage.removeItem('recordsFromBackendFor' + item.prototype.modelName);
ds = new OB.DS.DataSource(new OB.DS.Request(item, timestamp));
models._failedModels = models._failedModels || [];
issue36662_q1.diff [^] (4,512 bytes) 2017-09-11 11:44 [Show Content] [Hide Content]# HG changeset patch
# User Antonio Moreno <antonio.moreno@openbravo.com>
# Date 1503927040 -7200
# Mon Aug 28 15:30:40 2017 +0200
# Node ID 169b54b67af843f6f202430504cfcb69b91cce5b
# Parent 443b0a0eb45eeca9e03efe0080f6632ad046c624
Fixed issue 36662. Localdb will be forcefully refreshed after masterdata refresh has been done.
The problem reported by the customer seems to be related to the fact that the local database files are not cached initially by the operating system/browser, which means that the first search is very slow. Subsequent searches are then very fast, because after this initial query, the file is already cached.
The solution is to force the refresh and caching of the local database files after the masterdata models have been refreshed. To do this a simple query is executed for all models right after the loadModels function has finished.
diff -r 443b0a0eb45e -r 169b54b67af8 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Wed Aug 23 13:58:21 2017 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Mon Aug 28 15:30:40 2017 +0200
@@ -831,6 +831,18 @@
<!--6149E342C65048CE91979580BED5714E--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--6149E342C65048CE91979580BED5714E--></AD_MESSAGE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--><AD_MESSAGE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <AD_MESSAGE_ID><![CDATA[61CB4F9E6C7E4680B3EDD6D63D83CBF1]]></AD_MESSAGE_ID>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <VALUE><![CDATA[OBMOBC_ForcingRefreshOfLocalDatabase]]></VALUE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <MSGTEXT><![CDATA[Forcing refresh of local database]]></MSGTEXT>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <AD_MODULE_ID><![CDATA[08943B85ADF64E708797A753E5B6AAEE]]></AD_MODULE_ID>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--61CB4F9E6C7E4680B3EDD6D63D83CBF1--></AD_MESSAGE>
+
<!--6281AFF0B9134AA3AE8AADEA64F833D6--><AD_MESSAGE>
<!--6281AFF0B9134AA3AE8AADEA64F833D6--> <AD_MESSAGE_ID><![CDATA[6281AFF0B9134AA3AE8AADEA64F833D6]]></AD_MESSAGE_ID>
<!--6281AFF0B9134AA3AE8AADEA64F833D6--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 443b0a0eb45e -r 169b54b67af8 web/org.openbravo.mobile.core/source/data/ob-dal.js
--- a/web/org.openbravo.mobile.core/source/data/ob-dal.js Wed Aug 23 13:58:21 2017 +0200
+++ b/web/org.openbravo.mobile.core/source/data/ob-dal.js Mon Aug 28 15:30:40 2017 +0200
@@ -1497,6 +1497,22 @@
var somethigToLoad = false,
timestamp = 0;
+ var modelsInLocalDb = [];
+
+ function forceLocalDatabaseLoad(models, idx, callback) {
+ if (idx === models.length) {
+ if (callback) {
+ callback();
+ }
+ return;
+ }
+
+ OB.Dal.find(models[idx], {}, function () {
+ forceLocalDatabaseLoad(models, idx + 1, callback);
+ }, function () {
+ forceLocalDatabaseLoad(models, idx + 1, callback);
+ });
+ }
function triggerReady(models) {
if (incremental && models._LoadQueue && OB.UTIL.queueStatus(models._LoadQueue)) {
@@ -1516,7 +1532,11 @@
// If we are performing a full refresh of the data, now we can set the POSLastTotalRefresh timestamp.
OB.UTIL.localStorage.setItem('POSLastTotalRefresh', new Date().getTime());
}
- models.trigger('ready');
+ OB.UTIL.showLoadingMessage(OB.I18N.getLabel('OBMOBC_ForcingRefreshOfLocalDatabase'));
+ forceLocalDatabaseLoad(modelsInLocalDb, 0, function () {
+ models.trigger('ready');
+ });
+
} else {
// We know that the load of one or more models have failed.
// Reload the page to load all the models again.
@@ -1583,6 +1603,7 @@
if (incremental && OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName)) {
timestamp = OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName);
}
+ modelsInLocalDb.push(item);
ds = new OB.DS.DataSource(new OB.DS.Request(item, timestamp));
somethigToLoad = true;
models._failedModels = models._failedModels || [];
issue36662-2_q1.diff [^] (1,514 bytes) 2017-09-11 11:44 [Show Content] [Hide Content]# HG changeset patch
# User Antonio Moreno <antonio.moreno@openbravo.com>
# Date 1504004013 -7200
# Tue Aug 29 12:53:33 2017 +0200
# Node ID d060f32d8896bacee6f3d7d666b6494ac4d5a6dc
# Parent b90f916bbbd69e2ed37eef7f98a11f6e94e26932
Related to issue 36662. Added limit to avoid problems if model doesn't define a limit by default. Only refresh offline models.
diff -r b90f916bbbd6 -r d060f32d8896 web/org.openbravo.mobile.core/source/data/ob-dal.js
--- a/web/org.openbravo.mobile.core/source/data/ob-dal.js Mon Aug 28 15:30:40 2017 +0200
+++ b/web/org.openbravo.mobile.core/source/data/ob-dal.js Tue Aug 29 12:53:33 2017 +0200
@@ -1507,7 +1507,9 @@
return;
}
- OB.Dal.find(models[idx], {}, function () {
+ OB.Dal.find(models[idx], {
+ _limit: 100
+ }, function () {
forceLocalDatabaseLoad(models, idx + 1, callback);
}, function () {
forceLocalDatabaseLoad(models, idx + 1, callback);
@@ -1603,7 +1605,9 @@
if (incremental && OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName)) {
timestamp = OB.UTIL.localStorage.getItem('lastUpdatedTimestamp' + item.prototype.modelName);
}
- modelsInLocalDb.push(item);
+ if (!item.prototype.online) {
+ modelsInLocalDb.push(item);
+ }
ds = new OB.DS.DataSource(new OB.DS.Request(item, timestamp));
somethigToLoad = true;
models._failedModels = models._failedModels || [];
|