iobroker.sql 2.1.1 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/admin/i18n/de/translations.json +1 -1
- package/admin/i18n/zh-cn/translations.json +2 -2
- package/admin/words.js +3 -3
- package/io-package.json +38 -37
- package/lib/aggregate.js +278 -206
- package/main.js +29 -10
- package/package.json +3 -3
- package/admin/.gitignore +0 -0
package/README.md
CHANGED
|
@@ -520,6 +520,16 @@ sendTo('sql.0', 'getEnabledDPs', {}, function (result) {
|
|
|
520
520
|
-->
|
|
521
521
|
|
|
522
522
|
## Changelog
|
|
523
|
+
### 2.1.5 (2022-06-27)
|
|
524
|
+
* (Apollon77) When no count is provided for aggregate "none" or "onchange" then the limit (default 2000) is used as count to define the number of data to return.
|
|
525
|
+
* (Apollon77) Fix the initialization of types and IDs for some cases.
|
|
526
|
+
|
|
527
|
+
### 2.1.3 (2022-06-12)
|
|
528
|
+
* (Apollon77) Make sure debug log is active according to the settings
|
|
529
|
+
|
|
530
|
+
### 2.1.2 (2022-06-08)
|
|
531
|
+
* (Apollon77) Huge performance optimizations for GetHistory calls
|
|
532
|
+
|
|
523
533
|
### 2.1.1 (2022-05-30)
|
|
524
534
|
* (Apollon77) Fix crash cases reported by Sentry
|
|
525
535
|
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"Round real to": "Runden Sie bei der Abfrage die Zahlen auf",
|
|
51
51
|
"SQL history adapter settings": "SQL History Adapter Einstellungen",
|
|
52
52
|
"Start or enable adapter first": "Adapter muss zuerst aktiviert werden",
|
|
53
|
-
"Storage retention": "
|
|
53
|
+
"Storage retention": "Aufbewahrungsdauer",
|
|
54
54
|
"Store as": "Speichern als",
|
|
55
55
|
"String": "Zeichenfolge",
|
|
56
56
|
"Test connection": "Verbindung testen",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"Enter a number or leave the field empty": "输入一个数字或将该字段留空以不限制记录的值",
|
|
35
35
|
"File for sqlite": "申请sqlite",
|
|
36
36
|
"History adapter settings": "历史记录适配器设置",
|
|
37
|
-
"Host": "
|
|
37
|
+
"Host": "主机",
|
|
38
38
|
"Input path with the file name.": "例如。 ",
|
|
39
39
|
"Maximum concurrent connections": "最大并发连接数",
|
|
40
40
|
"Maximum concurrent connections:": "最大并发连接数:",
|
|
41
41
|
"Number": "数字",
|
|
42
42
|
"Number of days to keep the data.": "保留数据的天数。",
|
|
43
|
-
"Ok": "
|
|
43
|
+
"Ok": "确定",
|
|
44
44
|
"Password": "密码",
|
|
45
45
|
"Password confirm": "确认密码",
|
|
46
46
|
"Password confirmation is not equal with password!": "密码确认不等于密码!",
|
package/admin/words.js
CHANGED
|
@@ -37,13 +37,13 @@ systemDictionary = {
|
|
|
37
37
|
"Enter a number or leave the field empty": { "en": "Enter a number or leave the field empty to not limit the recorded values", "de": "Eine Zahl angeben oder das Feld leer lassen, um die aufgezeichneten Werte nicht einzuschränken", "ru": "Введите число или оставьте поле пустым, чтобы не ограничивать записываемые значения", "pt": "Digite um número ou deixe o campo vazio para não limitar os valores registrados", "nl": "Voer een getal in of laat het veld leeg om de geregistreerde waarden niet te beperken", "fr": "Entrez un nombre ou laissez le champ vide pour ne pas limiter les valeurs enregistrées", "it": "Immettere un numero o lasciare il campo vuoto per non limitare i valori registrati", "es": "Introduzca un número o deje el campo vacío para no limitar los valores registrados", "pl": "Wpisz liczbę lub pozostaw puste pole, aby nie ograniczać rejestrowanych wartości", "zh-cn": "输入一个数字或将该字段留空以不限制记录的值"},
|
|
38
38
|
"File for sqlite": { "en": "File for sqlite", "de": "Datei für sqlite", "ru": "Файл для sqlite", "pt": "Arquivo para sqlite", "nl": "Bestand voor sqlite", "fr": "Fichier pour sqlite", "it": "File per sqlite", "es": "Archivo para sqlite", "pl": "Plik dla sqlite", "zh-cn": "申请sqlite"},
|
|
39
39
|
"History adapter settings": { "en": "History adapter settings", "de": "History-Adapter Einstellungen", "ru": "Настройки драйвера history", "pt": "Configurações do adaptador de histórico", "nl": "Geschiedenis adapter instellingen", "fr": "Paramètres de l'adaptateur d'historique", "it": "Impostazioni della scheda Cronologia", "es": "Configuración del adaptador de historial", "pl": "Ustawienia adaptera historii", "zh-cn": "历史记录适配器设置"},
|
|
40
|
-
"Host": { "en": "Host", "de": "Server", "ru": "Хост", "pt": "Hospedeiro", "nl": "Host", "fr": "Hôte", "it": "Ospite", "es": "Anfitrión", "pl": "Gospodarz", "zh-cn": "
|
|
40
|
+
"Host": { "en": "Host", "de": "Server", "ru": "Хост", "pt": "Hospedeiro", "nl": "Host", "fr": "Hôte", "it": "Ospite", "es": "Anfitrión", "pl": "Gospodarz", "zh-cn": "主机"},
|
|
41
41
|
"Input path with the file name.": { "en": "E.g. /opt/sqlite/data.db", "de": "Z.B. /opt/sqlite/data.db", "ru": "Например /opt/sqlite/data.db", "pt": "Por exemplo. /opt/sqlite/data.db", "nl": "Bijv. /opt/sqlite/data.db", "fr": "Par exemple. /opt/sqlite/data.db", "it": "Per esempio. /opt/sqlite/data.db", "es": "P.ej. /opt/sqlite/data.db", "pl": "Na przykład. /opt/sqlite/data.db", "zh-cn": "例如。 "},
|
|
42
42
|
"Maximum concurrent connections": { "en": "Maximum concurrent connections", "de": "Max. gleichzeitige Verbindungen", "ru": "Максимальное количество одновременных подключений", "pt": "Máximo de conexões simultâneas", "nl": "Maximum aantal gelijktijdige verbindingen", "fr": "Nombre maximal de connexions simultanées", "it": "Numero massimo di connessioni simultanee", "es": "Máximas conexiones concurrentes", "pl": "Maksymalna liczba jednoczesnych połączeń", "zh-cn": "最大并发连接数"},
|
|
43
43
|
"Maximum concurrent connections:": { "en": "Maximum concurrent connections:", "de": "Maximale Anzahl parallele Verbindungen:", "ru": "Максимальное количество одновременных подключений:", "pt": "Máximo de conexões simultâneas:", "nl": "Maximale gelijktijdige verbindingen:", "fr": "Connexions simultanées maximales :", "it": "Numero massimo di connessioni simultanee:", "es": "Máximo de conexiones simultáneas:", "pl": "Maksymalna liczba jednoczesnych połączeń:", "zh-cn": "最大并发连接数:"},
|
|
44
44
|
"Number": { "en": "Number", "de": "Zahl", "ru": "Число", "pt": "Número", "nl": "Aantal", "fr": "Nombre", "it": "Numero", "es": "Numer", "pl": "Numer", "zh-cn": "数字"},
|
|
45
45
|
"Number of days to keep the data.": { "en": "Number of days to keep the data.", "de": "Anzahl der Tage, um die Daten aufzubewahren.", "ru": "Количество дней хранения данных.", "pt": "Número de dias para manter os dados.", "nl": "Aantal dagen om de gegevens te bewaren.", "fr": "Nombre de jours de conservation des données.", "it": "Numero di giorni di conservazione dei dati.", "es": "Número de días para conservar los datos.", "pl": "Liczba dni przechowywania danych.", "zh-cn": "保留数据的天数。"},
|
|
46
|
-
"Ok": { "en": "Ok", "de": "Ok", "ru": "Ok", "pt": "Ok", "nl": "OK", "fr": "D'accord", "it": "Ok", "es": "De acuerdo", "pl": "Ok", "zh-cn": "
|
|
46
|
+
"Ok": { "en": "Ok", "de": "Ok", "ru": "Ok", "pt": "Ok", "nl": "OK", "fr": "D'accord", "it": "Ok", "es": "De acuerdo", "pl": "Ok", "zh-cn": "确定"},
|
|
47
47
|
"Password": { "en": "Password", "de": "Passwort", "ru": "Пароль", "pt": "Senha", "nl": "Wachtwoord", "fr": "Mot de passe", "it": "Parola d'ordine", "es": "Contraseña", "pl": "Hasło", "zh-cn": "密码"},
|
|
48
48
|
"Password confirm": { "en": "Password confirm", "de": "Passwort-Wiederholung", "ru": "Подтверждение пароля", "pt": "Confirmação de senha", "nl": "Wachtwoord bevestigen", "fr": "Confirmer le mot de passe", "it": "Conferma la password", "es": "Contraseña confirmada", "pl": "Potwierdź hasło", "zh-cn": "确认密码"},
|
|
49
49
|
"Password confirmation is not equal with password!": {"en": "Password confirmation is not equal with password!", "de": "Passwort-Bestätigung stimmt nicht mit dem Passwort überein!", "ru": "Подтверждение пароля не совпадает с паролем!", "pt": "A confirmação da senha não é igual com a senha!", "nl": "Wachtwoordbevestiging is niet gelijk aan wachtwoord!", "fr": "La confirmation du mot de passe n'est pas égale au mot de passe!", "it": "La conferma della password non è uguale alla password!", "es": "La confirmación de la contraseña no es igual a la contraseña!", "pl": "Potwierdzenie hasła nie jest równe hasłu!", "zh-cn": "密码确认不等于密码!"},
|
|
@@ -53,7 +53,7 @@ systemDictionary = {
|
|
|
53
53
|
"Round real to": { "en": "On query round numbers to", "de": "Runden Sie bei der Abfrage die Zahlen auf", "ru": "По запросу округлить числа до", "pt": "Na consulta arredondar os números para", "nl": "Op query ronde getallen naar", "fr": "Sur requête arrondir les nombres à", "it": "Su interrogazione arrotondare i numeri a", "es": "En consulta números redondos a", "pl": "Na zapytanie okrągłe liczby do", "zh-cn": "在查询轮数到"},
|
|
54
54
|
"SQL history adapter settings": { "en": "SQL history adapter settings", "de": "SQL History Adapter Einstellungen", "ru": "Настройки профайлера в SQL базу данных", "pt": "Configurações do adaptador de histórico SQL", "nl": "Instellingen voor SQL-geschiedenisadapter", "fr": "Paramètres de l'adaptateur d'historique SQL", "it": "Impostazioni della scheda cronologia SQL", "es": "Configuración del adaptador de historial SQL", "pl": "Ustawienia adaptera historii SQL", "zh-cn": "SQL历史记录适配器设置"},
|
|
55
55
|
"Start or enable adapter first": { "en": "Start or enable adapter first", "de": "Adapter muss zuerst aktiviert werden", "ru": "Сначала надо запустить или активировать драйвер", "pt": "Inicie ou ative o adaptador primeiro", "nl": "Start of schakel eerst de adapter in", "fr": "Démarrer ou activer l'adaptateur en premier", "it": "Inizia o abilita prima l'adattatore", "es": "Comience o habilite el adaptador primero", "pl": "Najpierw włącz lub włącz adapter", "zh-cn": "首先启动或启用适配器"},
|
|
56
|
-
"Storage retention": { "en": "Storage retention", "de": "
|
|
56
|
+
"Storage retention": { "en": "Storage retention", "de": "Aufbewahrungsdauer", "ru": "Сохранять в файле", "pt": "Retenção de armazenamento", "nl": "Opslag retentie", "fr": "Conservation du stockage", "it": "Conservazione di memoria", "es": "Retención de almacenamiento", "pl": "Przechowywanie danych", "zh-cn": "存储保留"},
|
|
57
57
|
"Store as": { "en": "Store as", "de": "Speichern als", "ru": "Сохранить как", "pt": "Armazenar como", "nl": "Opslaan als", "fr": "Magasin comme", "it": "Conservare come", "es": "Przechowuj jako", "pl": "Przechowuj jako", "zh-cn": "存储为"},
|
|
58
58
|
"String": { "en": "String", "de": "Zeichenfolge", "ru": "строка", "pt": "Corda", "nl": "Draad", "fr": "Chaîne", "it": "Stringa", "es": "Strunowy", "pl": "Strunowy", "zh-cn": "细绳"},
|
|
59
59
|
"Test connection": { "en": "Test connection", "de": "Verbindung testen", "ru": "Проверить соединение", "pt": "Conexão de teste", "nl": "Test verbinding", "fr": "Test de connexion", "it": "Connessione di prova", "es": "Conexión de prueba", "pl": "Testuj połączenie", "zh-cn": "测试连接"},
|
package/io-package.json
CHANGED
|
@@ -26,8 +26,44 @@
|
|
|
26
26
|
"pl": "Rejestrowanie stanów w SQL DB",
|
|
27
27
|
"zh-cn": "将状态记录到SQL DB"
|
|
28
28
|
},
|
|
29
|
-
"version": "2.1.
|
|
29
|
+
"version": "2.1.5",
|
|
30
30
|
"news": {
|
|
31
|
+
"2.1.5": {
|
|
32
|
+
"en": "When no count is provided for aggregate \"none\" or \"onchange\" then the limit (default 2000) is used as count to define the number of data to return.\nFix the initialization of types and IDs for some cases.",
|
|
33
|
+
"de": "Wenn keine Zählung für die Aggregate keine oder Änderung vorgesehen ist, wird die Grenze (Standard 2000) als Zählung verwendet, um die Anzahl der Daten zu definieren, um zurückzukehren.\nBeheben Sie die Initialisierung von Typen und IDs für einige Fälle.",
|
|
34
|
+
"ru": "Когда никакое число не предусмотрено для агрегировать никакое или онмен после этого предел (по умолчанию 2000) использован как считать для того чтобы определить количество данных для возвращения.\nИсправьте инициализацию типов и идентификаторов для некоторых случаев.",
|
|
35
|
+
"pt": "Quando nenhuma contagem é fornecida para agregar nenhum ou onchange, então o limite (padrão 2000) é usado como contagem para definir o número de dados para retornar.\nCorrigir a inicialização de tipos e IDs para alguns casos.",
|
|
36
|
+
"nl": "Als er geen tel is voor aggregate noch onchange dan wordt de limiet (default 2000) gebruikt om het aantal data te definiëren om terug te keren.\nMaak de initialisatie van types en ID's voor sommige gevallen.",
|
|
37
|
+
"fr": "Si aucun compte n'est fourni pour l'agrégat aucun ou le changement, la limite (par défaut 2000) est utilisée comme compte pour définir le nombre de données à retourner.\nFixer l'initialisation des types et des ID pour certains cas.",
|
|
38
|
+
"it": "Quando non è previsto alcun conteggio per aggregato nessuno o per il cambiamento, il limite (default 2000) viene utilizzato come conteggio per definire il numero di dati da restituire.\nFissare l'inizializzazione di tipi e ID per alcuni casi.",
|
|
39
|
+
"es": "Cuando no se proporciona ningún recuento para agregado ninguno o cambio entonces el límite (por defecto 2000) se utiliza como recuento para definir el número de datos para regresar.\nArreglar la inicialización de tipos e identificaciones para algunos casos.",
|
|
40
|
+
"pl": "Jeśli nie jest liczona dla agregacji ani zmian, to limit (default 2000) jest używany jako określenie liczby danych do powrotu.\nW niektórych przypadkach inicjacja typów i ID.",
|
|
41
|
+
"zh-cn": "当时没有对总数据或换算进行计算(2000年12月)用于确定返回的数据数量。.\n确定某些案例的类型和研发。."
|
|
42
|
+
},
|
|
43
|
+
"2.1.3": {
|
|
44
|
+
"en": "Make sure debug log is active according to the settings",
|
|
45
|
+
"de": "Stellen Sie sicher, dass das Debug-Log gemäß den Einstellungen aktiv ist",
|
|
46
|
+
"ru": "Убедитесь, что журнал debug активен в соответствии с настройками",
|
|
47
|
+
"pt": "Certifique-se de que o log de depuração está ativo de acordo com as configurações",
|
|
48
|
+
"nl": "Zorg ervoor dat het logboek actief is volgens de instellingen",
|
|
49
|
+
"fr": "Assurez-vous que le journal debug est actif selon les paramètres",
|
|
50
|
+
"it": "Assicurarsi che il registro di debug sia attivo in base alle impostazioni",
|
|
51
|
+
"es": "Asegúrese de que el registro de depuración está activo según la configuración",
|
|
52
|
+
"pl": "Umożliwia to, że log debug jest aktywny zgodnie z ustawieniami",
|
|
53
|
+
"zh-cn": "B. 根据环境,确保有色色逻辑积极。"
|
|
54
|
+
},
|
|
55
|
+
"2.1.2": {
|
|
56
|
+
"en": "Huge performance optimizations for GetHistory calls",
|
|
57
|
+
"de": "Riesige Leistungsoptimierungen für GetHistory-Anrufe",
|
|
58
|
+
"ru": "Огромная оптимизация производительности для звонков GetHistory",
|
|
59
|
+
"pt": "Otimizações de desempenho enormes para chamadas GetHistory",
|
|
60
|
+
"nl": "Grote prestaties voor GetHistory",
|
|
61
|
+
"fr": "Des optimisations de performance énormes pour les appels GetHistory",
|
|
62
|
+
"it": "Ottimizzazione delle prestazioni enormi per le chiamate GetHistory",
|
|
63
|
+
"es": "Amplias optimizaciones de rendimiento para llamadas GetHistory",
|
|
64
|
+
"pl": "Optymalizacja wyników Huge'a dla GetHistory'ego nawołuje się do optymalizacji wydajności",
|
|
65
|
+
"zh-cn": "GetHistory呼声的优越性"
|
|
66
|
+
},
|
|
31
67
|
"2.1.1": {
|
|
32
68
|
"en": "Fix crash cases reported by Sentry",
|
|
33
69
|
"de": "Von Sentry gemeldete Absturzfälle beheben",
|
|
@@ -75,42 +111,6 @@
|
|
|
75
111
|
"es": "Datos interpolados marcados con `i=true`",
|
|
76
112
|
"pl": "Oznaczono dane interpolowane za pomocą `i=true`",
|
|
77
113
|
"zh-cn": "用 `i=true` 标记插值数据"
|
|
78
|
-
},
|
|
79
|
-
"1.16.1": {
|
|
80
|
-
"en": "Hide settings not relevant when \"log changes only\" is not used\nAllow all number values for debounce again",
|
|
81
|
-
"de": "Nicht relevante Einstellungen ausblenden, wenn \"Nur Änderungen protokollieren\" nicht verwendet wird\nAlle Zahlenwerte wieder für die Entprellung zulassen",
|
|
82
|
-
"ru": "Скрыть настройки, не актуальные, если не используется \"только изменения журнала\"\nРазрешить все числовые значения для устранения дребезга снова",
|
|
83
|
-
"pt": "Ocultar configurações irrelevantes quando \"apenas registro de alterações\" não é usado\nPermitir todos os valores numéricos para debounce novamente",
|
|
84
|
-
"nl": "Instellingen verbergen die niet relevant zijn wanneer \"alleen logboekwijzigingen\" niet wordt gebruikt\nSta alle getalwaarden opnieuw toe voor debounce",
|
|
85
|
-
"fr": "Masquer les paramètres non pertinents lorsque \"log changes only\" n'est pas utilisé\nAutoriser à nouveau toutes les valeurs numériques pour l'anti-rebond",
|
|
86
|
-
"it": "Nascondi le impostazioni non rilevanti quando \"solo modifiche al registro\" non viene utilizzato\nConsenti di nuovo l'antirimbalzo di tutti i valori numerici",
|
|
87
|
-
"es": "Ocultar la configuración que no es relevante cuando no se utiliza \"solo cambios de registro\"\nPermitir todos los valores numéricos para antirrebote nuevamente",
|
|
88
|
-
"pl": "Ukryj ustawienia nieistotne, gdy nie używasz opcji „tylko rejestruj zmiany”\nZezwól ponownie na odrzucenie wszystkich wartości liczbowych",
|
|
89
|
-
"zh-cn": "不使用“仅记录更改”时隐藏不相关的设置\n再次允许所有数值去抖动"
|
|
90
|
-
},
|
|
91
|
-
"1.16.0": {
|
|
92
|
-
"en": "Support only `js-controller` 3.3.x+\nUsed system/custom view for collecting the objects\nImplemented option to ignore zero- or/and below zero- values",
|
|
93
|
-
"de": "Unterstützt nur `js-controller` 3.3.x+\nVerwendete Systemansicht/benutzerdefinierte Ansicht zum Sammeln der Objekte\nImplementierte Option zum Ignorieren von Null- oder/und Unter-Null-Werten",
|
|
94
|
-
"ru": "Поддерживает только `js-controller` 3.3.x+\nИспользуемый системный / пользовательский вид для сбора объектов\nРеализована возможность игнорировать нулевые и / или отрицательные значения.",
|
|
95
|
-
"pt": "Suporte apenas `js-controller` 3.3.x+\nSistema usado / visão personalizada para coletar os objetos\nOpção implementada para ignorar valores zero ou / e abaixo de zero",
|
|
96
|
-
"nl": "Ondersteuning alleen `js-controller` 3.3.x+\nGebruikt systeem/aangepaste weergave voor het verzamelen van de objecten\nGeïmplementeerde optie om nul- of/en onder nul-waarden te negeren",
|
|
97
|
-
"fr": "Supporte uniquement `js-controller` 3.3.x+\nSystème utilisé/vue personnalisée pour la collecte des objets\nOption implémentée pour ignorer les valeurs zéro ou/et inférieures à zéro",
|
|
98
|
-
"it": "Supporta solo `js-controller` 3.3.x+\nSistema utilizzato/vista personalizzata per la raccolta degli oggetti\nOpzione implementata per ignorare i valori zero o/o inferiori a zero",
|
|
99
|
-
"es": "Admite solo `js-controller` 3.3.x+\nSistema usado / vista personalizada para recolectar los objetos.\nOpción implementada para ignorar valores cero o inferiores a cero",
|
|
100
|
-
"pl": "Obsługuje tylko `js-controller` 3.3.x+\nWykorzystany widok systemowy/niestandardowy do zbierania obiektów\nZaimplementowana opcja ignorowania wartości zerowych lub/i poniżej zera",
|
|
101
|
-
"zh-cn": "仅支持 `js-controller` 3.3.x+\n用于收集对象的系统/自定义视图\n已实现忽略零或/和低于零值的选项"
|
|
102
|
-
},
|
|
103
|
-
"1.15.7": {
|
|
104
|
-
"en": "fixed the support of Admin5",
|
|
105
|
-
"de": "Die Unterstützung von Admin5 wurde behoben",
|
|
106
|
-
"ru": "исправлена поддержка Admin5",
|
|
107
|
-
"pt": "consertou o suporte do Admin5",
|
|
108
|
-
"nl": "de ondersteuning van Admin5 opgelost",
|
|
109
|
-
"fr": "correction du support d'Admin5",
|
|
110
|
-
"it": "risolto il supporto di Admin5",
|
|
111
|
-
"es": "arreglado el soporte de Admin5",
|
|
112
|
-
"pl": "naprawiono obsługę Admin5",
|
|
113
|
-
"zh-cn": "修复了对Admin5的支持"
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
"mode": "daemon",
|
|
@@ -162,6 +162,7 @@
|
|
|
162
162
|
"custom": "json"
|
|
163
163
|
},
|
|
164
164
|
"tier": 1,
|
|
165
|
+
"eraseOnUpload": true,
|
|
165
166
|
"connectionType": "none",
|
|
166
167
|
"dataSource": "push",
|
|
167
168
|
"messages": [
|
package/lib/aggregate.js
CHANGED
|
@@ -48,25 +48,40 @@ function initAggregate(options) {
|
|
|
48
48
|
|
|
49
49
|
log(`${options.logId} Initialize: maxIndex = ${options.maxIndex}, step = ${options.step}, start = ${options.start}, end = ${options.end}`);
|
|
50
50
|
// pre-fill the result with timestamps (add one before start and one after end)
|
|
51
|
-
|
|
52
|
-
options.result
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
51
|
+
try {
|
|
52
|
+
options.result.length = options.maxIndex + 2;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
err.message += `: ${options.maxIndex + 2}`;
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
// We define the array length but do not prefill values, we do that on runtime when needed
|
|
58
|
+
options.result[0] = {
|
|
59
|
+
val: {ts: null, val: null},
|
|
60
|
+
max: {ts: null, val: null},
|
|
61
|
+
min: {ts: null, val: null},
|
|
62
|
+
start: {ts: null, val: null},
|
|
63
|
+
end: {ts: null, val: null}
|
|
64
|
+
};
|
|
65
|
+
options.result[options.maxIndex + 2] = {
|
|
66
|
+
val: {ts: null, val: null},
|
|
67
|
+
max: {ts: null, val: null},
|
|
68
|
+
min: {ts: null, val: null},
|
|
69
|
+
start: {ts: null, val: null},
|
|
70
|
+
end: {ts: null, val: null}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (options.aggregate === 'average') {
|
|
74
|
+
options.averageCount[0] = 0;
|
|
75
|
+
options.averageCount[options.maxIndex + 2] = 0;
|
|
76
|
+
}
|
|
63
77
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
if (options.aggregate === 'percentile' || options.aggregate === 'quantile') {
|
|
79
|
+
options.quantileDatapoints[0] = [];
|
|
80
|
+
options.quantileDatapoints[options.maxIndex + 2] = [];
|
|
81
|
+
}
|
|
82
|
+
if (options.aggregate === 'integral') {
|
|
83
|
+
options.integralDatapoints[0] = [];
|
|
84
|
+
options.integralDatapoints[options.maxIndex + 2] = [];
|
|
70
85
|
}
|
|
71
86
|
return options;
|
|
72
87
|
}
|
|
@@ -112,9 +127,25 @@ function aggregation(options, data) {
|
|
|
112
127
|
}
|
|
113
128
|
options.overallLength++;
|
|
114
129
|
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
if (options.result[index] === undefined) { // lazy initialization of datastructure
|
|
131
|
+
options.result[index] = {
|
|
132
|
+
val: {ts: null, val: null},
|
|
133
|
+
max: {ts: null, val: null},
|
|
134
|
+
min: {ts: null, val: null},
|
|
135
|
+
start: {ts: null, val: null},
|
|
136
|
+
end: {ts: null, val: null}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
if (options.aggregate === 'average') {
|
|
140
|
+
options.averageCount[index] = 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (options.aggregate === 'percentile' || options.aggregate === 'quantile') {
|
|
144
|
+
options.quantileDatapoints[index] = [];
|
|
145
|
+
}
|
|
146
|
+
if (options.aggregate === 'integral') {
|
|
147
|
+
options.integralDatapoints[index] = [];
|
|
148
|
+
}
|
|
118
149
|
}
|
|
119
150
|
|
|
120
151
|
aggregationLogic(data[i], index, options);
|
|
@@ -217,203 +248,220 @@ function finishAggregation(options) {
|
|
|
217
248
|
let postBorderValueRemoved = false;
|
|
218
249
|
const originalResultLength = options.result.length;
|
|
219
250
|
|
|
220
|
-
|
|
251
|
+
let startIndex = 0;
|
|
252
|
+
let endIndex = options.result.length;
|
|
253
|
+
const finalResult = [];
|
|
254
|
+
|
|
255
|
+
for (let ii = startIndex; ii < endIndex; ii++) {
|
|
221
256
|
// no one value in this period
|
|
222
|
-
if (options.result[ii].start.ts === null) {
|
|
257
|
+
if (options.result[ii] === undefined || options.result[ii].start.ts === null) {
|
|
223
258
|
if (ii === 0) {
|
|
224
259
|
preBorderValueRemoved = true;
|
|
225
260
|
} else if (ii === originalResultLength - 1) {
|
|
226
261
|
postBorderValueRemoved = true;
|
|
227
262
|
}
|
|
228
|
-
options.result.splice(ii, 1);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
options.result[ii].end.ts === options.result[ii].min.ts) {
|
|
241
|
-
options.result.splice(ii + 1, 0, {
|
|
242
|
-
ts: options.result[ii].end.ts,
|
|
243
|
-
val: options.result[ii].end.val
|
|
244
|
-
});
|
|
245
|
-
options.result[ii] = {
|
|
246
|
-
ts: options.result[ii].start.ts,
|
|
247
|
-
val: options.result[ii].start.val
|
|
248
|
-
};
|
|
249
|
-
} // if just 3 values: start, min == max, end
|
|
250
|
-
else {
|
|
251
|
-
options.result.splice(ii + 1, 0, {
|
|
252
|
-
ts: options.result[ii].max.ts,
|
|
253
|
-
val: options.result[ii].max.val
|
|
254
|
-
});
|
|
255
|
-
options.result.splice(ii + 2, 0, {
|
|
256
|
-
ts: options.result[ii].end.ts,
|
|
257
|
-
val: options.result[ii].end.val
|
|
258
|
-
});
|
|
259
|
-
options.result[ii] = {
|
|
260
|
-
ts: options.result[ii].start.ts,
|
|
261
|
-
val: options.result[ii].start.val
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
} else
|
|
265
|
-
if (options.result[ii].start.ts === options.result[ii].max.ts) {
|
|
266
|
-
// just one value in this period: start == max, min == end
|
|
267
|
-
if (options.result[ii].min.ts === options.result[ii].end.ts) {
|
|
268
|
-
options.result.splice(ii + 1, 0, {
|
|
269
|
-
ts: options.result[ii].end.ts,
|
|
270
|
-
val: options.result[ii].end.val
|
|
271
|
-
});
|
|
272
|
-
options.result[ii] = {
|
|
273
|
-
ts: options.result[ii].start.ts,
|
|
274
|
-
val: options.result[ii].start.val
|
|
275
|
-
};
|
|
276
|
-
} // start == max, min, end
|
|
277
|
-
else {
|
|
278
|
-
options.result.splice(ii + 1, 0, {
|
|
279
|
-
ts: options.result[ii].min.ts,
|
|
280
|
-
val: options.result[ii].min.val
|
|
281
|
-
});
|
|
282
|
-
options.result.splice(ii + 2, 0, {
|
|
283
|
-
ts: options.result[ii].end.ts,
|
|
284
|
-
val: options.result[ii].end.val
|
|
285
|
-
});
|
|
286
|
-
options.result[ii] = {
|
|
287
|
-
ts: options.result[ii].start.ts,
|
|
288
|
-
val: options.result[ii].start.val
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
} else
|
|
292
|
-
if (options.result[ii].end.ts === options.result[ii].max.ts) {
|
|
293
|
-
// just one value in this period: start == min, max == end
|
|
294
|
-
if (options.result[ii].min.ts === options.result[ii].start.ts) {
|
|
295
|
-
options.result.splice(ii + 1, 0, {
|
|
296
|
-
ts: options.result[ii].end.ts,
|
|
297
|
-
val: options.result[ii].end.val
|
|
298
|
-
});
|
|
299
|
-
options.result[ii] = {
|
|
300
|
-
ts: options.result[ii].start.ts,
|
|
301
|
-
val: options.result[ii].start.val
|
|
302
|
-
};
|
|
303
|
-
} // start, min, max == end
|
|
304
|
-
else {
|
|
305
|
-
options.result.splice(ii + 1, 0, {
|
|
306
|
-
ts: options.result[ii].min.ts,
|
|
307
|
-
val: options.result[ii].min.val
|
|
308
|
-
});
|
|
309
|
-
options.result.splice(ii + 2, 0, {
|
|
310
|
-
ts: options.result[ii].end.ts,
|
|
311
|
-
val: options.result[ii].end.val
|
|
312
|
-
});
|
|
313
|
-
options.result[ii] = {
|
|
314
|
-
ts: options.result[ii].start.ts,
|
|
315
|
-
val: options.result[ii].start.val
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
} else
|
|
263
|
+
//options.result.splice(ii, 1);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
// just one value in this period: max == min == start == end
|
|
267
|
+
if (options.result[ii].start.ts === options.result[ii].end.ts) {
|
|
268
|
+
finalResult.push({
|
|
269
|
+
ts: options.result[ii].start.ts,
|
|
270
|
+
val: options.result[ii].start.val
|
|
271
|
+
});
|
|
272
|
+
} else
|
|
273
|
+
if (options.result[ii].min.ts === options.result[ii].max.ts) {
|
|
274
|
+
// if just 2 values: start == min == max, end
|
|
319
275
|
if (options.result[ii].start.ts === options.result[ii].min.ts ||
|
|
320
276
|
options.result[ii].end.ts === options.result[ii].min.ts) {
|
|
321
|
-
|
|
322
|
-
|
|
277
|
+
finalResult.push({
|
|
278
|
+
ts: options.result[ii].start.ts,
|
|
279
|
+
val: options.result[ii].start.val
|
|
280
|
+
});
|
|
281
|
+
finalResult.push({
|
|
282
|
+
ts: options.result[ii].end.ts,
|
|
283
|
+
val: options.result[ii].end.val
|
|
284
|
+
});
|
|
285
|
+
} // if just 3 values: start, min == max, end
|
|
286
|
+
else {
|
|
287
|
+
finalResult.push({
|
|
288
|
+
ts: options.result[ii].start.ts,
|
|
289
|
+
val: options.result[ii].start.val
|
|
290
|
+
});
|
|
291
|
+
finalResult.push({
|
|
323
292
|
ts: options.result[ii].max.ts,
|
|
324
293
|
val: options.result[ii].max.val
|
|
325
294
|
});
|
|
326
|
-
|
|
295
|
+
finalResult.push({
|
|
327
296
|
ts: options.result[ii].end.ts,
|
|
328
297
|
val: options.result[ii].end.val
|
|
329
298
|
});
|
|
330
|
-
|
|
299
|
+
}
|
|
300
|
+
} else
|
|
301
|
+
if (options.result[ii].start.ts === options.result[ii].max.ts) {
|
|
302
|
+
// just one value in this period: start == max, min == end
|
|
303
|
+
if (options.result[ii].min.ts === options.result[ii].end.ts) {
|
|
304
|
+
finalResult.push({
|
|
331
305
|
ts: options.result[ii].start.ts,
|
|
332
306
|
val: options.result[ii].start.val
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
options.result.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
options.result.
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
options.result.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
307
|
+
});
|
|
308
|
+
finalResult.push({
|
|
309
|
+
ts: options.result[ii].end.ts,
|
|
310
|
+
val: options.result[ii].end.val
|
|
311
|
+
});
|
|
312
|
+
} // start == max, min, end
|
|
313
|
+
else {
|
|
314
|
+
finalResult.push({
|
|
315
|
+
ts: options.result[ii].start.ts,
|
|
316
|
+
val: options.result[ii].start.val
|
|
317
|
+
});
|
|
318
|
+
finalResult.push({
|
|
319
|
+
ts: options.result[ii].min.ts,
|
|
320
|
+
val: options.result[ii].min.val
|
|
321
|
+
});
|
|
322
|
+
finalResult.push({
|
|
323
|
+
ts: options.result[ii].end.ts,
|
|
324
|
+
val: options.result[ii].end.val
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
} else
|
|
328
|
+
if (options.result[ii].end.ts === options.result[ii].max.ts) {
|
|
329
|
+
// just one value in this period: start == min, max == end
|
|
330
|
+
if (options.result[ii].min.ts === options.result[ii].start.ts) {
|
|
331
|
+
finalResult.push({
|
|
332
|
+
ts: options.result[ii].start.ts,
|
|
333
|
+
val: options.result[ii].start.val
|
|
334
|
+
});
|
|
335
|
+
finalResult.push({
|
|
356
336
|
ts: options.result[ii].end.ts,
|
|
357
337
|
val: options.result[ii].end.val
|
|
358
338
|
});
|
|
359
|
-
|
|
339
|
+
} // start, min, max == end
|
|
340
|
+
else {
|
|
341
|
+
finalResult.push({
|
|
360
342
|
ts: options.result[ii].start.ts,
|
|
361
343
|
val: options.result[ii].start.val
|
|
362
|
-
};
|
|
344
|
+
});
|
|
345
|
+
finalResult.push({
|
|
346
|
+
ts: options.result[ii].min.ts,
|
|
347
|
+
val: options.result[ii].min.val
|
|
348
|
+
});
|
|
349
|
+
finalResult.push({
|
|
350
|
+
ts: options.result[ii].end.ts,
|
|
351
|
+
val: options.result[ii].end.val
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
} else
|
|
355
|
+
if (options.result[ii].start.ts === options.result[ii].min.ts ||
|
|
356
|
+
options.result[ii].end.ts === options.result[ii].min.ts) {
|
|
357
|
+
// just one value in this period: start == min, max, end
|
|
358
|
+
finalResult.push({
|
|
359
|
+
ts: options.result[ii].start.ts,
|
|
360
|
+
val: options.result[ii].start.val
|
|
361
|
+
});
|
|
362
|
+
finalResult.push({
|
|
363
|
+
ts: options.result[ii].max.ts,
|
|
364
|
+
val: options.result[ii].max.val
|
|
365
|
+
});
|
|
366
|
+
finalResult.push({
|
|
367
|
+
ts: options.result[ii].end.ts,
|
|
368
|
+
val: options.result[ii].end.val
|
|
369
|
+
});
|
|
370
|
+
} else {
|
|
371
|
+
finalResult.push({
|
|
372
|
+
ts: options.result[ii].start.ts,
|
|
373
|
+
val: options.result[ii].start.val
|
|
374
|
+
});
|
|
375
|
+
// just one value in this period: start == min, max, end
|
|
376
|
+
if (options.result[ii].max.ts > options.result[ii].min.ts) {
|
|
377
|
+
finalResult.push({
|
|
378
|
+
ts: options.result[ii].min.ts,
|
|
379
|
+
val: options.result[ii].min.val
|
|
380
|
+
});
|
|
381
|
+
finalResult.push({
|
|
382
|
+
ts: options.result[ii].max.ts,
|
|
383
|
+
val: options.result[ii].max.val
|
|
384
|
+
});
|
|
385
|
+
} else {
|
|
386
|
+
finalResult.push({
|
|
387
|
+
ts: options.result[ii].max.ts,
|
|
388
|
+
val: options.result[ii].max.val
|
|
389
|
+
});
|
|
390
|
+
finalResult.push({
|
|
391
|
+
ts: options.result[ii].min.ts,
|
|
392
|
+
val: options.result[ii].min.val
|
|
393
|
+
});
|
|
363
394
|
}
|
|
395
|
+
finalResult.push({
|
|
396
|
+
ts: options.result[ii].end.ts,
|
|
397
|
+
val: options.result[ii].end.val
|
|
398
|
+
});
|
|
364
399
|
}
|
|
365
400
|
}
|
|
366
401
|
if (options.removeBorderValues) { // we cut out the additional results
|
|
367
402
|
if (!preBorderValueRemoved) {
|
|
368
|
-
|
|
403
|
+
finalResult.splice(0, 1);
|
|
369
404
|
}
|
|
370
405
|
if (!postBorderValueRemoved) {
|
|
371
|
-
|
|
406
|
+
finalResult.length--;
|
|
372
407
|
}
|
|
373
408
|
}
|
|
409
|
+
options.result = finalResult;
|
|
374
410
|
} else if (options.aggregate === 'average') {
|
|
411
|
+
let startIndex = 0;
|
|
412
|
+
let endIndex = options.result.length;
|
|
413
|
+
const finalResult = [];
|
|
375
414
|
if (options.removeBorderValues) { // we cut out the additional results
|
|
376
|
-
options.result.splice(0, 1);
|
|
377
|
-
options.averageCount.splice(0, 1);
|
|
378
|
-
options.result.
|
|
379
|
-
options.averageCount.
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
415
|
+
// options.result.splice(0, 1);
|
|
416
|
+
// options.averageCount.splice(0, 1);
|
|
417
|
+
// options.result.length--;
|
|
418
|
+
// options.averageCount.length--;
|
|
419
|
+
startIndex++;
|
|
420
|
+
endIndex--;
|
|
421
|
+
}
|
|
422
|
+
for (let k = startIndex; k < endIndex; k++) {
|
|
423
|
+
if (options.result[k] !== undefined && options.result[k].val.ts) {
|
|
424
|
+
finalResult.push({
|
|
384
425
|
ts: options.result[k].val.ts,
|
|
385
426
|
val: options.result[k].val.val !== null ? Math.round(options.result[k].val.val / options.averageCount[k] * 100) / 100 : null
|
|
386
|
-
};
|
|
427
|
+
});
|
|
387
428
|
} else {
|
|
388
429
|
// no one value in this interval
|
|
389
|
-
options.result.splice(k, 1);
|
|
390
|
-
options.averageCount.splice(k, 1);
|
|
430
|
+
//options.result.splice(k, 1);
|
|
431
|
+
//options.averageCount.splice(k, 1); // not needed to clean up because not used anymore afterwards
|
|
391
432
|
}
|
|
392
433
|
}
|
|
434
|
+
options.result = finalResult;
|
|
393
435
|
} else if (options.aggregate === 'integral') {
|
|
436
|
+
let preBorderValueRemoved = false;
|
|
437
|
+
let postBorderValueRemoved = false;
|
|
438
|
+
const originalResultLength = options.result.length;
|
|
439
|
+
const finalResult = [];
|
|
440
|
+
|
|
394
441
|
for (let k = 0; k < options.result.length; k++) {
|
|
395
442
|
let indexStartTs = options.start + ((k - 1) * options.step);
|
|
396
443
|
let indexEndTs = indexStartTs + options.step;
|
|
397
|
-
if (options.integralDatapoints[k].length) {
|
|
444
|
+
if (options.integralDatapoints[k] && options.integralDatapoints[k].length) {
|
|
398
445
|
// Sort datapoints by ts first
|
|
399
446
|
options.integralDatapoints[k].sort(sortByTs);
|
|
400
447
|
}
|
|
401
448
|
// Make sure that we have entries that always start at the beginning of the interval
|
|
402
|
-
if ((!options.integralDatapoints[k].length || options.integralDatapoints[k][0].ts > indexStartTs) && options.integralDatapoints[k - 1] && options.integralDatapoints[k -1][options.integralDatapoints[k - 1].length - 1]) {
|
|
449
|
+
if ((!options.integralDatapoints[k] || !options.integralDatapoints[k].length || options.integralDatapoints[k][0].ts > indexStartTs) && options.integralDatapoints[k - 1] && options.integralDatapoints[k -1][options.integralDatapoints[k - 1].length - 1]) {
|
|
403
450
|
// if the first entry of this interval started somewhere in the start of the interval, add a start entry
|
|
404
451
|
// same if there is no entry at all in the timeframe, use last entry from interval before
|
|
452
|
+
options.integralDatapoints[k] = options.integralDatapoints[k] || [];
|
|
405
453
|
options.integralDatapoints[k].unshift({
|
|
406
454
|
ts: indexStartTs,
|
|
407
455
|
val: options.integralDatapoints[k - 1][options.integralDatapoints[k - 1].length - 1].val
|
|
408
456
|
});
|
|
409
457
|
log(`${options.logId} Integral: ${k}: Added start entry for interval with ts=${indexStartTs}, val=${options.integralDatapoints[k][0].val}`);
|
|
410
|
-
} else if (options.integralDatapoints[k].length && options.integralDatapoints[k][0].ts > indexStartTs) {
|
|
458
|
+
} else if (options.integralDatapoints[k] && options.integralDatapoints[k].length && options.integralDatapoints[k][0].ts > indexStartTs) {
|
|
411
459
|
options.integralDatapoints[k].unshift({
|
|
412
460
|
ts: indexStartTs,
|
|
413
461
|
val: options.integralDatapoints[k][0].val
|
|
414
462
|
});
|
|
415
463
|
log(`${options.logId} Integral: ${k}: Added start entry for interval with ts=${indexStartTs}, val=${options.integralDatapoints[k][0].val} with same value as first point in interval because no former datapoint was found`);
|
|
416
|
-
} else if (options.integralDatapoints[k].length && options.integralDatapoints[k][0].ts < indexStartTs) {
|
|
464
|
+
} else if (options.integralDatapoints[k] && options.integralDatapoints[k].length && options.integralDatapoints[k][0].ts < indexStartTs) {
|
|
417
465
|
// if the first entry of this interval started before the start of the interval, search for the last value before the start of the interval, add as start entry
|
|
418
466
|
let preFirstIndex = null;
|
|
419
467
|
for (let kk = 0; kk < options.integralDatapoints[k].length; kk++) {
|
|
@@ -431,32 +479,35 @@ function finishAggregation(options) {
|
|
|
431
479
|
}
|
|
432
480
|
}
|
|
433
481
|
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (!options.result[k].val.ts) {
|
|
438
|
-
options.result[k].val.ts = Math.round(options.start + (((k - 1) + 0.5) * options.step));
|
|
482
|
+
const point = {
|
|
483
|
+
ts: options.result[k] !== undefined && options.result[k].val.ts ? options.result[k].val.ts : Math.round(options.start + (((k - 1) + 0.5) * options.step)),
|
|
484
|
+
val: null
|
|
439
485
|
}
|
|
486
|
+
|
|
487
|
+
const integralDatapoints = options.integralDatapoints[k] || [];
|
|
488
|
+
const vals = integralDatapoints.map(dp => `[${dp.ts}, ${dp.val}]`);
|
|
489
|
+
log(`${options.logId} Integral: ${k}: ${integralDatapoints.length} datapoints for interval for ${indexStartTs} - ${indexEndTs}: ${vals.join(',')}`);
|
|
490
|
+
|
|
440
491
|
// Calculate Intervals and always calculate till the interval end (start made sure above already)
|
|
441
|
-
for (let kk = 0; kk <
|
|
442
|
-
const valEndTs =
|
|
443
|
-
let valDuration = valEndTs -
|
|
492
|
+
for (let kk = 0; kk < integralDatapoints.length; kk++) {
|
|
493
|
+
const valEndTs = integralDatapoints[kk + 1] ? Math.min(integralDatapoints[kk + 1].ts, indexEndTs) : indexEndTs;
|
|
494
|
+
let valDuration = valEndTs - integralDatapoints[kk].ts;
|
|
444
495
|
if (valDuration < 0) {
|
|
445
|
-
log(`${options.logId} Integral: ${k}[${kk}] data do not belong to this interval, ignore ${JSON.stringify(
|
|
496
|
+
log(`${options.logId} Integral: ${k}[${kk}] data do not belong to this interval, ignore ${JSON.stringify(integralDatapoints[kk])} (vs. ${valEndTs})`)
|
|
446
497
|
break;
|
|
447
498
|
}
|
|
448
499
|
if (valDuration === 0) {
|
|
449
|
-
log(`${options.logId} Integral: ${k}[${kk}] valDuration zero, ignore ${JSON.stringify(
|
|
500
|
+
log(`${options.logId} Integral: ${k}[${kk}] valDuration zero, ignore ${JSON.stringify(integralDatapoints[kk])}`)
|
|
450
501
|
continue;
|
|
451
502
|
}
|
|
452
|
-
let valStart = parseFloat(
|
|
503
|
+
let valStart = parseFloat(integralDatapoints[kk].val) || 0;
|
|
453
504
|
// End value is the next value, or if none, assume "linearity
|
|
454
|
-
let valEnd = parseFloat((
|
|
505
|
+
let valEnd = parseFloat((integralDatapoints[kk + 1] ? integralDatapoints[kk + 1].val : (options.integralDatapoints[k + 1] && options.integralDatapoints[k + 1][0] ? options.integralDatapoints[k + 1][0].val : valStart))) || 0;
|
|
455
506
|
if (options.integralInterpolation !== 'linear' || valStart === valEnd) {
|
|
456
507
|
const integralAdd = valStart * valDuration / options.integralUnit;
|
|
457
508
|
// simple rectangle linear interpolation
|
|
458
509
|
log(`${options.logId} Integral: ${k}[${kk}] : Add ${integralAdd} from val=${valStart} for ${valDuration}`);
|
|
459
|
-
|
|
510
|
+
point.val += integralAdd;
|
|
460
511
|
} else if ((valStart >= 0 && valEnd >= 0) || (valStart <= 0 && valEnd <= 0)) {
|
|
461
512
|
// start and end are both positive or both negative, or one is 0
|
|
462
513
|
let multiplier = 1;
|
|
@@ -471,7 +522,7 @@ function finishAggregation(options) {
|
|
|
471
522
|
const trianglePart = (maxVal - minVal) * valDuration * 0.5 / options.integralUnit;
|
|
472
523
|
const integralAdd = (rectPart + trianglePart) * multiplier;
|
|
473
524
|
log(`${options.logId} Integral: ${k}[${kk}] : Add R${rectPart} + T${trianglePart} => ${integralAdd} from val=${valStart} to ${valEnd} for ${valDuration}`);
|
|
474
|
-
|
|
525
|
+
point.val += integralAdd;
|
|
475
526
|
} else {
|
|
476
527
|
// Values are on different sides of 0, so we need to find the 0 crossing
|
|
477
528
|
const zeroCrossing = Math.abs((valStart * valDuration) / (valEnd - valStart));
|
|
@@ -480,60 +531,81 @@ function finishAggregation(options) {
|
|
|
480
531
|
const trianglePart2 = valEnd * (valDuration - zeroCrossing) * 0.5 / options.integralUnit;
|
|
481
532
|
const integralAdd = trianglePart1 + trianglePart2;
|
|
482
533
|
log(`${options.logId} Integral: ${k}[${kk}] : Add T${trianglePart1} + T${trianglePart2} => ${integralAdd} from val=${valStart} to ${valEnd} for ${valDuration} (zero crossing ${zeroCrossing})`);
|
|
483
|
-
|
|
534
|
+
point.val += integralAdd;
|
|
484
535
|
}
|
|
485
536
|
}
|
|
486
|
-
options.result[k] = {
|
|
487
|
-
ts:
|
|
537
|
+
/*options.result[k] = {
|
|
538
|
+
ts: options.result[k].val.ts,
|
|
488
539
|
val: options.result[k].val.val
|
|
540
|
+
}*/
|
|
541
|
+
if (point.val !== null) {
|
|
542
|
+
finalResult.push(point);
|
|
543
|
+
} else {
|
|
544
|
+
if (k === 0) {
|
|
545
|
+
preBorderValueRemoved = true;
|
|
546
|
+
} else if (k === originalResultLength - 1) {
|
|
547
|
+
postBorderValueRemoved = true;
|
|
548
|
+
}
|
|
489
549
|
}
|
|
490
550
|
}
|
|
491
551
|
if (options.removeBorderValues) { // we cut out the additional results
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
// no one value in this interval
|
|
498
|
-
options.result.splice(j, 1);
|
|
552
|
+
if (!preBorderValueRemoved) {
|
|
553
|
+
finalResult.splice(0, 1);
|
|
554
|
+
}
|
|
555
|
+
if (!postBorderValueRemoved) {
|
|
556
|
+
finalResult.length--;
|
|
499
557
|
}
|
|
500
558
|
}
|
|
559
|
+
options.result = finalResult;
|
|
501
560
|
} else if (options.aggregate === 'percentile' || options.aggregate === 'quantile') {
|
|
561
|
+
let startIndex = 0;
|
|
562
|
+
let endIndex = options.result.length;
|
|
563
|
+
const finalResult = [];
|
|
502
564
|
if (options.removeBorderValues) { // we cut out the additional results
|
|
503
|
-
options.result.splice(0, 1);
|
|
565
|
+
/*options.result.splice(0, 1);
|
|
504
566
|
options.quantileDatapoints.splice(0, 1);
|
|
505
|
-
options.result.
|
|
506
|
-
options.quantileDatapoints.
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
567
|
+
options.result.length--
|
|
568
|
+
options.quantileDatapoints.length--;*/
|
|
569
|
+
startIndex++;
|
|
570
|
+
endIndex--;
|
|
571
|
+
}
|
|
572
|
+
for (let k = startIndex; k < endIndex; k++) {
|
|
573
|
+
if (options.result[k] !== undefined && options.result[k].val.ts) {
|
|
574
|
+
const point = {
|
|
511
575
|
ts: options.result[k].val.ts,
|
|
512
576
|
val: quantile(options.quantile, options.quantileDatapoints[k])
|
|
513
577
|
};
|
|
514
|
-
log(`${options.logId} Quantile ${k} ${
|
|
578
|
+
log(`${options.logId} Quantile ${k} ${point.ts}: ${options.quantileDatapoints[k].join(', ')} -> ${point.val}`);
|
|
579
|
+
finalResult.push(point);
|
|
515
580
|
} else {
|
|
516
581
|
// no one value in this interval
|
|
517
|
-
options.result.splice(k, 1);
|
|
518
|
-
options.quantileDatapoints.splice(k, 1);
|
|
582
|
+
//options.result.splice(k, 1);
|
|
583
|
+
//options.quantileDatapoints.splice(k, 1); // not needed to clean up because not used anymore afterwards
|
|
519
584
|
}
|
|
520
585
|
}
|
|
586
|
+
options.result = finalResult;
|
|
521
587
|
} else {
|
|
588
|
+
let startIndex = 0;
|
|
589
|
+
let endIndex = options.result.length;
|
|
590
|
+
const finalResult = [];
|
|
522
591
|
if (options.removeBorderValues) { // we cut out the additional results
|
|
523
|
-
options.result.splice(0, 1);
|
|
524
|
-
options.result.
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
592
|
+
// options.result.splice(0, 1);
|
|
593
|
+
// options.result.length--;
|
|
594
|
+
startIndex++;
|
|
595
|
+
endIndex--;
|
|
596
|
+
}
|
|
597
|
+
for (let j = startIndex; j < endIndex; j++) {
|
|
598
|
+
if (options.result[j] !== undefined && options.result[j].val.ts) {
|
|
599
|
+
finalResult.push({
|
|
529
600
|
ts: options.result[j].val.ts,
|
|
530
601
|
val: options.result[j].val.val
|
|
531
|
-
};
|
|
602
|
+
});
|
|
532
603
|
} else {
|
|
533
604
|
// no one value in this interval
|
|
534
|
-
options.result.splice(j, 1);
|
|
605
|
+
//options.result.splice(j, 1);
|
|
535
606
|
}
|
|
536
607
|
}
|
|
608
|
+
options.result = finalResult;
|
|
537
609
|
}
|
|
538
610
|
|
|
539
611
|
beautify(options);
|
|
@@ -680,7 +752,7 @@ function beautify(options) {
|
|
|
680
752
|
}
|
|
681
753
|
} else if (options.aggregate === 'none') {
|
|
682
754
|
if (options.count && options.result.length > options.count) {
|
|
683
|
-
options.result
|
|
755
|
+
options.result.splice(0, options.result.length - options.count);
|
|
684
756
|
}
|
|
685
757
|
}
|
|
686
758
|
|
|
@@ -725,7 +797,7 @@ function sendResponse(adapter, msg, options, data, startTime) {
|
|
|
725
797
|
beautify(options);
|
|
726
798
|
|
|
727
799
|
if (options.aggregate === 'none' && options.count && options.result.length > options.count) {
|
|
728
|
-
options.result
|
|
800
|
+
options.result.splice(0, options.result.length - options.count);
|
|
729
801
|
}
|
|
730
802
|
aggregateData.result = options.result;
|
|
731
803
|
} else {
|
|
@@ -789,7 +861,7 @@ function sendResponseCounter(adapter, msg, options, data, startTime) {
|
|
|
789
861
|
}
|
|
790
862
|
|
|
791
863
|
if (data[data.length - 2].ts === options.end) {
|
|
792
|
-
data.
|
|
864
|
+
data.length--;
|
|
793
865
|
}
|
|
794
866
|
|
|
795
867
|
const veryLast = data[data.length - 1];
|
|
@@ -798,7 +870,7 @@ function sendResponseCounter(adapter, msg, options, data, startTime) {
|
|
|
798
870
|
// interpolate from end time to last
|
|
799
871
|
if (options.end < veryLast.ts) {
|
|
800
872
|
const val = beforeLast.val + (veryLast.val - beforeLast.val) * ((options.end - beforeLast.ts) / (veryLast.ts - beforeLast.ts));
|
|
801
|
-
data.
|
|
873
|
+
data.length--;
|
|
802
874
|
data.push({ts: options.end, val, i: true});
|
|
803
875
|
}
|
|
804
876
|
|
package/main.js
CHANGED
|
@@ -1557,7 +1557,7 @@ function processReadTypes() {
|
|
|
1557
1557
|
|
|
1558
1558
|
if (!sqlDPs[task.id]) {
|
|
1559
1559
|
adapter.log.warn(`Ignore type lookup for ${task.id} because not enabled anymore`);
|
|
1560
|
-
task.cb && task.cb(`Ignore type lookup for ${task.id} because not enabled anymore`)
|
|
1560
|
+
task.cb && task.cb(`Ignore type lookup for ${task.id} because not enabled anymore`);
|
|
1561
1561
|
task.cb = null;
|
|
1562
1562
|
return setImmediate(() => {
|
|
1563
1563
|
tasksReadType.shift();
|
|
@@ -1634,6 +1634,7 @@ function processReadTypes() {
|
|
|
1634
1634
|
task.cb && task.cb();
|
|
1635
1635
|
task.cb = null;
|
|
1636
1636
|
tasksReadType.shift();
|
|
1637
|
+
processReadTypes();
|
|
1637
1638
|
}
|
|
1638
1639
|
});
|
|
1639
1640
|
}
|
|
@@ -1859,7 +1860,7 @@ function storeCached(onlyId, cb) {
|
|
|
1859
1860
|
sqlDPs[id].list = [];
|
|
1860
1861
|
count++;
|
|
1861
1862
|
pushValuesIntoDB(id, sqlDPs[id].inFlight[inFlightId], err => {
|
|
1862
|
-
delete sqlDPs[id].inFlight[inFlightId];
|
|
1863
|
+
sqlDPs[id].inFlight && sqlDPs[id].inFlight[inFlightId] && delete sqlDPs[id].inFlight[inFlightId];
|
|
1863
1864
|
if (!--count && cb) {
|
|
1864
1865
|
cb(err);
|
|
1865
1866
|
cb = null;
|
|
@@ -2327,7 +2328,7 @@ function getHistory(msg) {
|
|
|
2327
2328
|
start: msg.message.options.start,
|
|
2328
2329
|
end: msg.message.options.end || (Date.now() + 5000000),
|
|
2329
2330
|
step: parseInt(msg.message.options.step, 10) || null,
|
|
2330
|
-
count: parseInt(msg.message.options.count, 10)
|
|
2331
|
+
count: parseInt(msg.message.options.count, 10),
|
|
2331
2332
|
ignoreNull: msg.message.options.ignoreNull,
|
|
2332
2333
|
aggregate: msg.message.options.aggregate || 'average', // One of: max, min, average, total, none, on-change
|
|
2333
2334
|
limit: parseInt(msg.message.options.limit, 10) || parseInt(msg.message.options.count, 10) || adapter.config.limit || 2000,
|
|
@@ -2346,6 +2347,16 @@ function getHistory(msg) {
|
|
|
2346
2347
|
logId: (msg.message.id ? msg.message.id : 'all') + Date.now() + Math.random()
|
|
2347
2348
|
};
|
|
2348
2349
|
|
|
2350
|
+
adapter.log.debug(`${options.logId} getHistory message: ${JSON.stringify(msg.message)}`);
|
|
2351
|
+
|
|
2352
|
+
if (!options.count || isNaN(options.count)) {
|
|
2353
|
+
if (options.aggregate === 'none' || options.aggregate === 'onchange') {
|
|
2354
|
+
options.count = options.limit;
|
|
2355
|
+
} else {
|
|
2356
|
+
options.count = 500;
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2349
2360
|
try {
|
|
2350
2361
|
if (options.start && typeof options.start !== 'number') {
|
|
2351
2362
|
options.start = new Date(options.start).getTime();
|
|
@@ -2381,8 +2392,6 @@ function getHistory(msg) {
|
|
|
2381
2392
|
options.round = adapter.config.round;
|
|
2382
2393
|
}
|
|
2383
2394
|
|
|
2384
|
-
adapter.log.debug(`${options.logId} getHistory call: ${JSON.stringify(options)}`);
|
|
2385
|
-
|
|
2386
2395
|
if (options.id && aliasMap[options.id]) {
|
|
2387
2396
|
options.id = aliasMap[options.id];
|
|
2388
2397
|
}
|
|
@@ -2403,7 +2412,7 @@ function getHistory(msg) {
|
|
|
2403
2412
|
}
|
|
2404
2413
|
|
|
2405
2414
|
sqlDPs[options.id] = sqlDPs[options.id] || {};
|
|
2406
|
-
const debugLog = options.debugLog = !!(sqlDPs[options.id] && sqlDPs[options.id][adapter.namespace] && sqlDPs[options.id][adapter.namespace].enableDebugLogs);
|
|
2415
|
+
const debugLog = options.debugLog = !!((sqlDPs[options.id] && sqlDPs[options.id][adapter.namespace] && sqlDPs[options.id][adapter.namespace].enableDebugLogs) || adapter.config.enableDebugLogs);
|
|
2407
2416
|
|
|
2408
2417
|
if (options.ignoreNull === 'true') options.ignoreNull = true; // include nulls and replace them with last value
|
|
2409
2418
|
if (options.ignoreNull === 'false') options.ignoreNull = false; // include nulls
|
|
@@ -2422,6 +2431,8 @@ function getHistory(msg) {
|
|
|
2422
2431
|
options.start = Date.now() - 86400000; // - 1 day
|
|
2423
2432
|
}
|
|
2424
2433
|
|
|
2434
|
+
debugLog && adapter.log.debug(`${options.logId} getHistory options final: ${JSON.stringify(options)}`);
|
|
2435
|
+
|
|
2425
2436
|
if (sqlDPs[options.id].type === undefined && sqlDPs[options.id].dbtype !== undefined) {
|
|
2426
2437
|
if (sqlDPs[options.id][adapter.namespace] && sqlDPs[options.id][adapter.namespace].storageType) {
|
|
2427
2438
|
if (storageTypes.indexOf(sqlDPs[options.id][adapter.namespace].storageType) === sqlDPs[options.id].dbtype) {
|
|
@@ -2470,7 +2481,7 @@ function getHistory(msg) {
|
|
|
2470
2481
|
if ((isFull && cacheData.length) && (options.aggregate === 'onchange' || options.aggregate === '' || options.aggregate === 'none')) {
|
|
2471
2482
|
cacheData = cacheData.sort(sortByTs);
|
|
2472
2483
|
if (options.count && cacheData.length > options.count && options.aggregate === 'none') {
|
|
2473
|
-
cacheData
|
|
2484
|
+
cacheData.splice(0, cacheData.length - options.count);
|
|
2474
2485
|
debugLog && adapter.log.debug(`${options.logId} cut cacheData to ${options.count} values`);
|
|
2475
2486
|
}
|
|
2476
2487
|
adapter.log.debug(`${options.logId} Send: ${cacheData.length} values in: ${Date.now() - startTime}ms`);
|
|
@@ -2507,13 +2518,17 @@ function getHistory(msg) {
|
|
|
2507
2518
|
}
|
|
2508
2519
|
}
|
|
2509
2520
|
}
|
|
2510
|
-
data
|
|
2521
|
+
data.splice(options.count);
|
|
2511
2522
|
options.debugLog && adapter.log.debug(`${options.logId} pre-cut data to ${options.count} oldest values`);
|
|
2512
2523
|
}
|
|
2513
2524
|
|
|
2514
2525
|
data.sort(sortByTs);
|
|
2515
2526
|
}
|
|
2516
|
-
|
|
2527
|
+
try {
|
|
2528
|
+
commons.sendResponse(adapter, msg, options, (err ? err.toString() : null) || data, startTime)
|
|
2529
|
+
} catch (e) {
|
|
2530
|
+
commons.sendResponse(adapter, msg, options, e.toString(), startTime);
|
|
2531
|
+
}
|
|
2517
2532
|
});
|
|
2518
2533
|
}
|
|
2519
2534
|
});
|
|
@@ -2537,7 +2552,11 @@ function getHistory(msg) {
|
|
|
2537
2552
|
}
|
|
2538
2553
|
if (!--count) {
|
|
2539
2554
|
rows.sort(sortByTs);
|
|
2540
|
-
|
|
2555
|
+
try {
|
|
2556
|
+
commons.sendResponse(adapter, msg, options, rows, startTime);
|
|
2557
|
+
} catch (e) {
|
|
2558
|
+
commons.sendResponse(adapter, msg, options, e.toString(), startTime);
|
|
2559
|
+
}
|
|
2541
2560
|
}
|
|
2542
2561
|
});
|
|
2543
2562
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.sql",
|
|
3
3
|
"description": "Log state sql in a two-stages process (first to Redis, then to CouchDB)",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.5",
|
|
5
5
|
"author": "bluefox <dogafox@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"bluefox <dogafox@gmail.com>",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"optionalDependencies": {
|
|
24
24
|
"mysql2": "^2.3.3",
|
|
25
25
|
"pg": "^8.7.3",
|
|
26
|
-
"sqlite3": "^5.0.
|
|
27
|
-
"mssql": "^8.1.
|
|
26
|
+
"sqlite3": "^5.0.8",
|
|
27
|
+
"mssql": "^8.1.2"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"sql-client": "^3.0.0",
|
package/admin/.gitignore
DELETED
|
File without changes
|