From b8c905bd648ff18ebe12e2f6b2622fea4dce57a4 Mon Sep 17 00:00:00 2001 From: simon987 Date: Sun, 8 Oct 2023 21:00:03 -0400 Subject: [PATCH] expose indexRoot value to documents --- sist2-vue/src/Sist2Api.js | 19 +++++++------------ src/sist.h | 4 ++-- src/web/serve.c | 10 +++++++--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sist2-vue/src/Sist2Api.js b/sist2-vue/src/Sist2Api.js index dcc5b4a..dc47049 100644 --- a/sist2-vue/src/Sist2Api.js +++ b/sist2-vue/src/Sist2Api.js @@ -33,18 +33,6 @@ class Sist2Api { getSist2Info() { return axios.get(`${this.baseUrl}i`).then(resp => { - const indices = resp.data.indices; - - resp.data.indices = indices.map(idx => { - return { - id: idx.id, - name: idx.name, - timestamp: idx.timestamp, - version: idx.version, - models: idx.models, - }; - }); - this.sist2Info = resp.data; return resp.data; @@ -155,6 +143,12 @@ class Sist2Api { } } + _getIndexRoot(indexId) { + console.log(indexId) + console.log(this.sist2Info.indices.find(idx => idx.id === indexId)) + return this.sist2Info.indices.find(idx => idx.id === indexId).root; + } + esQuery(query) { return axios.post(`${this.baseUrl}es`, query).then(resp => { const res = resp.data; @@ -163,6 +157,7 @@ class Sist2Api { res.hits.hits.forEach((hit) => { hit["_source"]["name"] = strUnescape(hit["_source"]["name"]); hit["_source"]["path"] = strUnescape(hit["_source"]["path"]); + hit["_source"]["indexRoot"] = this._getIndexRoot(hit["_source"]["index"]); this.setHitProps(hit); this.setHitTags(hit); diff --git a/src/sist.h b/src/sist.h index d4e5d29..fbd0ffd 100644 --- a/src/sist.h +++ b/src/sist.h @@ -51,11 +51,11 @@ #include #include "git_hash.h" -#define VERSION "3.3.4" +#define VERSION "3.3.5" static const char *const Version = VERSION; static const int VersionMajor = 3; static const int VersionMinor = 3; -static const int VersionPatch = 4; +static const int VersionPatch = 5; #ifndef SIST_PLATFORM #define SIST_PLATFORM unknown diff --git a/src/web/serve.c b/src/web/serve.c index 0eacf7a..b9af2f5 100644 --- a/src/web/serve.c +++ b/src/web/serve.c @@ -88,7 +88,7 @@ void stats_files(struct mg_connection *nc, struct mg_http_message *hm) { memcpy(index_id_str, hm->uri.ptr + 3, 8); *(index_id_str + 8) = '\0'; - int index_id = (int)strtol(index_id_str, NULL, 16); + int index_id = (int) strtol(index_id_str, NULL, 16); memcpy(arg_stat_type, hm->uri.ptr + 3 + 9, 4); *(arg_stat_type + sizeof(arg_stat_type) - 1) = '\0'; @@ -368,6 +368,10 @@ void index_info(struct mg_connection *nc) { cJSON_AddNumberToObject(idx_json, "timestamp", (double) idx->desc.timestamp); cJSON_AddItemToArray(arr, idx_json); +#ifdef SIST_DEBUG_INFO + cJSON_AddStringToObject(idx_json, "root", idx->desc.root); +#endif + cJSON *models = database_get_models(idx->db); cJSON_AddItemToObject(idx_json, "models", models); } @@ -480,7 +484,7 @@ tag_req_t *parse_tag_request(cJSON *json) { return req; } -subreq_ctx_t *elastic_delete_tag(const char* sid, const tag_req_t *req) { +subreq_ctx_t *elastic_delete_tag(const char *sid, const tag_req_t *req) { char *buf = malloc(sizeof(char) * 8192); snprintf(buf, 8192, "{" @@ -500,7 +504,7 @@ subreq_ctx_t *elastic_delete_tag(const char* sid, const tag_req_t *req) { return web_post_async(url, buf, WebCtx.es_insecure_ssl); } -subreq_ctx_t *elastic_write_tag(const char* sid, const tag_req_t *req) { +subreq_ctx_t *elastic_write_tag(const char *sid, const tag_req_t *req) { char *buf = malloc(sizeof(char) * 8192); snprintf(buf, 8192, "{"