Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close 1.5.4 #287

Merged
merged 7 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions OpenFlow/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class dbConfig extends Base {
if(["license_key", "otel_trace_url", "cache_store_type", "cache_store_redis_host", "cache_store_max", "grafana_url", "workitem_queue_monitoring_interval",
"NODE_ENV", "validate_emails", "amqp_url", "port", "saml_issuer", "saml_federation_metadata", "api_ws_url",
"domain", "enable_openapi", "enable_openapiauth", "ping_clients_interval", "tls_crt", "tls_key", "tls_ca",
"otel_metric_url", "otel_trace_url", "multi_tenant" ].indexOf(key) > -1 ) {
"otel_metric_url", "otel_trace_url", "multi_tenant", "auto_hourly_housekeeping" ].indexOf(key) > -1 ) {
if(os.hostname().toLowerCase() == "nixos") {
continue;
}
Expand Down Expand Up @@ -118,7 +118,7 @@ export class dbConfig extends Base {
if(["license_key", "otel_trace_url", "cache_store_type", "cache_store_redis_host", "cache_store_max", "grafana_url", "workitem_queue_monitoring_interval",
"NODE_ENV", "validate_emails", "amqp_url", "port", "saml_issuer", "saml_federation_metadata", "api_ws_url",
"domain", "enable_openapi", "enable_openapiauth", "ping_clients_interval", "tls_crt", "tls_key", "tls_ca",
"otel_metric_url", "otel_trace_url", "multi_tenant" ].indexOf(key) > -1 ) {
"otel_metric_url", "otel_trace_url", "multi_tenant", "auto_hourly_housekeeping" ].indexOf(key) > -1 ) {
if(os.hostname().toLowerCase() == "nixos") {
continue;
}
Expand Down
55 changes: 36 additions & 19 deletions OpenFlow/src/DatabaseConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4580,6 +4580,41 @@ export class DatabaseConnection extends events.EventEmitter {
public static timeseries_collections: string[] = [];
public static timeseries_collections_metadata: any = {};
public static timeseries_collections_time: any = {};
public async UpdateIndexTypes(parent: Span) {
try {
let collections = await DatabaseConnection.toArray(this.db.listCollections());
collections = collections.filter(x => x.name.indexOf("system.") === -1);

DatabaseConnection.timeseries_collections = [];
for (let i = 0; i < collections.length; i++) {
var collection = collections[i];
if (collection.type == "timeseries") {
DatabaseConnection.timeseries_collections = DatabaseConnection.timeseries_collections.filter(x => x != collection.name);
DatabaseConnection.timeseries_collections.push(collection.name);
}
}
DatabaseConnection.timeseries_collections = [];
DatabaseConnection.collections_with_text_index = [];
for (let i = 0; i < collections.length; i++) {
var collection = collections[i];
if (collection.type == "timeseries") {
DatabaseConnection.timeseries_collections = DatabaseConnection.timeseries_collections.filter(x => x != collection.name);
DatabaseConnection.timeseries_collections.push(collection.name);
}
if (collection.type != "collection" && collection.type != "timeseries") continue;
parent?.addEvent("Get indexes for " + collection.name);
const indexes = await this.db.collection(collection.name).indexes();
for (let y = 0; y < indexes.length; y++) {
var idx = indexes[y];
if (idx.textIndexVersion && idx.textIndexVersion > 1 && collection.name != "fs.files") {
DatabaseConnection.collections_with_text_index = DatabaseConnection.collections_with_text_index.filter(x => x != collection.name);
DatabaseConnection.collections_with_text_index.push(collection.name);
}
}
}
} catch (error) {
}
}
async ensureindexes(parent: Span) {
const span: Span = Logger.otel.startSubSpan("db.ensureindexes", parent);
try {
Expand All @@ -4597,25 +4632,7 @@ export class DatabaseConnection extends events.EventEmitter {
}
}
if (!Config.ensure_indexes) {
DatabaseConnection.timeseries_collections = [];
DatabaseConnection.collections_with_text_index = [];
for (let i = 0; i < collections.length; i++) {
var collection = collections[i];
if (collection.type == "timeseries") {
DatabaseConnection.timeseries_collections = DatabaseConnection.timeseries_collections.filter(x => x != collection.name);
DatabaseConnection.timeseries_collections.push(collection.name);
}
if (collection.type != "collection" && collection.type != "timeseries") continue;
span?.addEvent("Get indexes for " + collection.name);
const indexes = await this.db.collection(collection.name).indexes();
for (let y = 0; y < indexes.length; y++) {
var idx = indexes[y];
if (idx.textIndexVersion && idx.textIndexVersion > 1 && collection.name != "fs.files") {
DatabaseConnection.collections_with_text_index = DatabaseConnection.collections_with_text_index.filter(x => x != collection.name);
DatabaseConnection.collections_with_text_index.push(collection.name);
}
}
}
await this.UpdateIndexTypes(span);
return;
}

Expand Down
1 change: 1 addition & 0 deletions OpenFlow/src/Messages/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3610,6 +3610,7 @@ export class Message {
Logger.otel.endSpan(span);
}
}

public async _Housekeeping(skipNodered: boolean, skipCalculateSize: boolean, skipUpdateUserSize: boolean, parent: Span): Promise<void> {
if (Message.lastHouseKeeping == null) {
Message.lastHouseKeeping = new Date();
Expand Down
4 changes: 4 additions & 0 deletions OpenFlow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ async function initDatabase(parent: Span): Promise<boolean> {
cerror(error);
process.exit(404);
}
try {
await Config.db.UpdateIndexTypes(span);
} catch (error) {
}



Expand Down
8 changes: 5 additions & 3 deletions OpenFlow/src/public/CommonControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,21 +727,23 @@ export class entitiesCtrl<T> {

}
}
if (this.WebSocketClientService.collections_with_text_index.indexOf(this.collection) == -1) {
if (this.WebSocketClientService.timeseries_collections.indexOf(this.collection) == -1 &&
this.WebSocketClientService.collections_with_text_index.indexOf(this.collection) == -1) {
if (NoderedUtil.IsNullUndefinded(this.orderby) || Object.keys(this.orderby).length == 0) {
orderby = { _created: -1 };
}
} else {
if (NoderedUtil.IsNullUndefinded(this.orderby) || Object.keys(this.orderby).length == 0) {
orderby = { _created: -1 };
if(this.collection == "audit" || this.collection == "dbusage") {
orderby = { _created: -1 };
}
}
if (!NoderedUtil.IsNullEmpty(this.searchstring) && !this.searchstring.startsWith(".")) {
// Remove order by when using text index
orderby = null;
}
}
if (this.page == 0) {

this.models = await NoderedUtil.Query({ collectionname: this.collection, query, projection: this.baseprojection, orderby, top: this.pagesize, queryas: basequeryas });
} else {
var temp = await NoderedUtil.Query({ collectionname: this.collection, query, projection: this.baseprojection, orderby, top: this.pagesize, skip: this.pagesize * this.page, queryas: basequeryas });
Expand Down
2 changes: 2 additions & 0 deletions OpenFlow/src/public/Controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,7 @@ export class EntitiesCtrl extends entitiesCtrl<Base> {
if (!this.$scope.$$phase) { this.$scope.$apply(); }
}
SelectCollection() {
if (!this.userdata.data.EntitiesCtrl) this.userdata.data.EntitiesCtrl = {};
this.userdata.data.EntitiesCtrl.collection = this.collection;
this.$location.path("/Entities/" + this.collection);
//this.$location.hash("#/Entities/" + this.collection);
Expand Down Expand Up @@ -8332,6 +8333,7 @@ export class AgentCtrl extends entityCtrl<any> {
this.basequery = { _id: this.id };
await NoderedUtil.CustomCommand({ command: "startagent", id: this.model._id, name: this.model.slug })
}
this.$location.path("/Agent/" + this.id);
}
this.loading = false;
if (this.model) { this.loadData(); }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openiap/openflow",
"version": "1.5.3",
"version": "1.5.4",
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
"main": "index.js",
"scripts": {
Expand Down
Loading