MCPcopy Index your code
hub / github.com/buildbot/buildbot / put

Method put

www/data-module/src/data/DataCollection.ts:153–192  ·  view source on GitHub ↗
(element: any)

Source from the content-addressed store, hash-verified

151 }
152
153 @action put(element: any) {
154 const id = element[this.descriptor.fieldId];
155 if (!this.resolved) {
156 this.idsBeforeResolve.add(String(id));
157 }
158
159 const old = this.byId.get(String(id));
160 if (old !== undefined) {
161 if (!this.queryExecutor.isAllowedByFilters(element)) {
162 // existing item, but updated data has property that filters out the element outright
163 if (this.queryExecutor.limit !== null &&
164 this.array.length === this.queryExecutor.limit &&
165 this.byId.size > this.array.length)
166 {
167 // Array was limited, however there are more up-to-date data in byId that can be filled
168 // in.
169 this.byId.delete(String(id));
170 this.array.replace([...this.byId.values()]);
171 this.recomputeQuery();
172 } else {
173 this.byId.delete(String(id));
174 this.deleteFromArray(old);
175 }
176 return;
177 }
178 // update items that are not filtered out
179 old.update(element);
180 return;
181 }
182
183 if (!this.queryExecutor.isAllowedByFilters(element)) {
184 // ignore items that are filtered out
185 return;
186 }
187
188 // add items that are not filtered out
189 const instance = this.descriptor.parse(this.accessor, element);
190 this.byId.set(instance.id, instance);
191 this.array.push(instance);
192 }
193
194 @action clear() {
195 this.array.replace([]);

Callers 2

listenerMethod · 0.95
initialMethod · 0.95

Calls 11

recomputeQueryMethod · 0.95
deleteFromArrayMethod · 0.95
isAllowedByFiltersMethod · 0.80
pushMethod · 0.80
getMethod · 0.65
parseMethod · 0.65
StringClass · 0.50
addMethod · 0.45
deleteMethod · 0.45
updateMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected