MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / _get_changes

Method _get_changes

api/edge_api/identities/models.py:254–293  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

252 )
253
254 def _get_changes(self) -> IdentityChangeset:
255 previous_instance = self._initial_state
256 changes = {} # type: ignore[var-annotated]
257 feature_changes = changes.setdefault("feature_overrides", {})
258 previous_feature_overrides = {
259 fs.featurestate_uuid: fs for fs in previous_instance.feature_overrides
260 }
261 current_feature_overrides = {
262 fs.featurestate_uuid: fs for fs in self.feature_overrides
263 }
264
265 for uuid_, previous_fs in previous_feature_overrides.items():
266 current_matching_fs = current_feature_overrides.get(uuid_)
267 if current_matching_fs is None:
268 feature_changes[previous_fs.feature.name] = generate_change_dict(
269 change_type="-",
270 identity_id=self.id,
271 old=previous_fs,
272 )
273 elif (
274 current_matching_fs.enabled != previous_fs.enabled
275 or current_matching_fs.get_value(self.id)
276 != previous_fs.get_value(self.id)
277 ):
278 feature_changes[previous_fs.feature.name] = generate_change_dict(
279 change_type="~",
280 identity_id=self.id,
281 new=current_matching_fs,
282 old=previous_fs,
283 )
284
285 for uuid_, previous_fs in current_feature_overrides.items():
286 if uuid_ not in previous_feature_overrides:
287 feature_changes[previous_fs.feature.name] = generate_change_dict(
288 change_type="+",
289 identity_id=self.id,
290 new=previous_fs,
291 )
292
293 return changes # type: ignore[return-value]
294
295 def _reset_initial_state(self): # type: ignore[no-untyped-def]
296 self._initial_state = copy.deepcopy(self)

Callers 2

saveMethod · 0.95
deleteMethod · 0.95

Calls 3

generate_change_dictFunction · 0.90
getMethod · 0.45
get_valueMethod · 0.45

Tested by

no test coverage detected