PluginProbe
ElasticPress / 4.3.1
ElasticPress v4.3.1
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
elasticpress / assets / js / sync / utilities.js

utilities.js in ElasticPress 4.3.1, at assets/js/sync/utilities.js

60 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Clear sync parameter from the URL.
3 *
4 * @returns {void}
5 */
6 export const clearSyncParam = () => {
7 window.history.replaceState(
8 {},
9 document.title,
10 document.location.pathname + document.location.search.replace(/&do_sync/, ''),
11 );
12 };
13
14 /**
15 * Get the total number of items from index meta.
16 *
17 * @param {object} indexMeta Index meta.
18 * @returns {number} Number of items.
19 */
20 export const getItemsTotalFromIndexMeta = (indexMeta) => {
21 let itemsTotal = 0;
22
23 if (indexMeta.current_sync_item) {
24 itemsTotal += indexMeta.current_sync_item.found_items;
25 }
26
27 itemsTotal = indexMeta.sync_stack.reduce(
28 (itemsTotal, sync) => itemsTotal + sync.found_items,
29 itemsTotal,
30 );
31
32 itemsTotal += indexMeta.totals.failed;
33 itemsTotal += indexMeta.totals.skipped;
34 itemsTotal += indexMeta.totals.synced;
35
36 return itemsTotal;
37 };
38
39 /**
40 * Get the number of processed items from index meta.
41 *
42 * @param {object} indexMeta Index meta.
43 * @returns {number} Number of processed items.
44 */
45 export const getItemsProcessedFromIndexMeta = (indexMeta) => {
46 let itemsProcessed = 0;
47
48 if (indexMeta.current_sync_item) {
49 itemsProcessed += indexMeta.current_sync_item.failed;
50 itemsProcessed += indexMeta.current_sync_item.skipped;
51 itemsProcessed += indexMeta.current_sync_item.synced;
52 }
53
54 itemsProcessed += indexMeta.totals.failed;
55 itemsProcessed += indexMeta.totals.skipped;
56 itemsProcessed += indexMeta.totals.synced;
57
58 return itemsProcessed;
59 };
60