@@ -118,22 +118,26 @@ def _get_super_entities_by_ctype(model_objs_by_ctype, model_ids_to_sync, sync_al
118118 return super_entities_by_ctype
119119
120120
121- def _fetch_entity_models (model_ids_to_sync , model_objs_map , model_objs_by_ctype ):
121+ def _fetch_entity_models (model_ids_to_sync , model_objs_map , model_objs_by_ctype , sync_all ):
122122 """
123123 Fetch the entity models per content type. This will also handle the
124124 case where accounts are created before _get_super_entities_by_ctype and
125125 the model_ids_to_sync do not match the model_objs_map
126126 """
127127 for ctype , model_ids in model_ids_to_sync .items ():
128128
129- # Build a set of ids of already fetched models
130- fetched_model_ids = {
131- model .id
132- for model in model_objs_by_ctype [ctype ]
133- }
129+ if sync_all :
130+
131+ # Build a set of ids of already fetched models
132+ fetched_model_ids = {
133+ model .id
134+ for model in model_objs_by_ctype [ctype ]
135+ }
134136
135- # Compute the set diff to see if any records are missing
136- unfetched_model_ids = model_ids - fetched_model_ids
137+ # Compute the set diff to see if any records are missing
138+ unfetched_model_ids = model_ids - fetched_model_ids
139+ else :
140+ unfetched_model_ids = model_ids
137141
138142 # Check if new records
139143 if unfetched_model_ids :
@@ -146,13 +150,13 @@ def _fetch_entity_models(model_ids_to_sync, model_objs_map, model_objs_by_ctype)
146150 model_objs_map [(ctype , model_obj .id )] = model_obj
147151
148152
149- def _get_model_objs_to_sync (model_ids_to_sync , model_objs_map , model_objs_by_ctype ):
153+ def _get_model_objs_to_sync (model_ids_to_sync , model_objs_map , model_objs_by_ctype , sync_all ):
150154 """
151155 Given the model IDs to sync, fetch all model objects to sync
152156 """
153157 model_objs_to_sync = {}
154158
155- _fetch_entity_models (model_ids_to_sync , model_objs_map , model_objs_by_ctype )
159+ _fetch_entity_models (model_ids_to_sync , model_objs_map , model_objs_by_ctype , sync_all )
156160
157161 for ctype , model_ids_to_sync_for_ctype in model_ids_to_sync .items ():
158162 model_objs_to_sync [ctype ] = [
@@ -261,7 +265,7 @@ def sync(self):
261265 # Now that we have all models we need to sync, fetch them so that we can extract
262266 # metadata and entity kinds. If we are syncing all entities, we've already fetched
263267 # everything and can fill in this data struct without doing another DB hit
264- model_objs_to_sync = _get_model_objs_to_sync (model_ids_to_sync , model_objs_map , model_objs_by_ctype )
268+ model_objs_to_sync = _get_model_objs_to_sync (model_ids_to_sync , model_objs_map , model_objs_by_ctype , sync_all )
265269
266270 # Obtain all entity kind tuples associated with the models
267271 entity_kind_tuples_to_sync = set ()
0 commit comments