Skip to content

Commit

Permalink
tweak(Tinebase) change record.copy() implementation
Browse files Browse the repository at this point in the history
speeds up crewscheduling with large data sets by 20 times
  • Loading branch information
corneliusweiss committed Feb 28, 2025
1 parent 7ed5cdc commit f7b2a07
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tine20/library/ExtJS/src/data/Record.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const { extend, isPrimitive, isEmpty } = require("Ext/core/core/Ext");
const Field = require("Ext/data/DataField");
const MixedCollection = require("Ext/util/MixedCollection");
const { cloneDeep, forEach } = require('lodash');
const { get, isFunction, isUndefined, forEach } = require('lodash');

/**
* @class Record
Expand Down Expand Up @@ -413,7 +413,24 @@ Record.id(rec); // automatically generate a unique sequential id
* @return {Record}
*/
copy : function(newId) {
return new this.constructor(cloneDeep(this.data), newId || this.id);
const data = this.getData();
data[this.idProperty] = isUndefined(newId) ? data[this.idProperty] : newId;
const copy = Tine.Tinebase.data.Record.setFromJson(data, this.constructor);
forEach(this.data, (v, k) => {
if (isFunction(get(v, 'copy'))) {
this.data[k] = v.copy();
}
});
forEach(this.__metaFields, (m) => {
if (this.hasOwnProperty(m)) {
copy[m] = this[m];
}
});
copy.modified = [];
forEach(this.modified, (v, k) => {
copy.modified[k] = isFunction(get(v, 'copy')) ? v.copy() : this.modified[k];
});
return copy;
},

/**
Expand Down

0 comments on commit f7b2a07

Please sign in to comment.