@@ -173,34 +173,37 @@ def get_linked_parents(db, instance):
173
173
curr_node_parents = get_linked_parents (db , curr_node )
174
174
175
175
for parent in curr_node_parents :
176
- if parent in sorted_list :
177
- sorted_list .remove (parent )
178
- sorted_list .append (parent )
179
- elif parent not in unvisited_nodes :
176
+ if parent not in unvisited_nodes :
180
177
unvisited_nodes .append (parent )
178
+
179
+ trimmed_list = [] #remove duplicates
180
+
181
+ for instance in reversed (sorted_list ):
182
+ if instance not in trimmed_list :
183
+ trimmed_list .insert (0 ,instance )
181
184
182
185
with open ("backend/endpoints/logfile.txt" , "a" ) as log_file :
183
186
184
187
log_file .write ("curr_instance begin\n " )
185
188
log_file .write (f"{ curr_instance } \n " )
186
189
log_file .write ("curr_instance end\n \n " )
187
190
188
- log_file .write ("sorted_list begin\n " )
189
- for node in sorted_list :
191
+ log_file .write ("trimmed_list begin\n " )
192
+ for node in trimmed_list :
190
193
log_file .write (f"{ documents .get_document (api , node )["name" ]} \n " )
191
- log_file .write ("sorted_list end\n \n " )
194
+ log_file .write ("trimmed_list end\n \n " )
192
195
193
196
194
- for instance in sorted_list :
197
+ for instance in trimmed_list :
195
198
require_permissions (api , instance , Permission .WRITE , Permission .LINK )
196
199
197
200
versions .create_version (api , curr_instance , name , description )
198
201
199
202
updated_references = 0
200
- for update_instance in sorted_list :
203
+ for update_instance in trimmed_list :
201
204
202
205
updated_references += do_update_references (
203
- api , update_instance , [doc .document_id for doc in sorted_list ]
206
+ api , update_instance , [doc .document_id for doc in trimmed_list ]
204
207
)
205
208
versions .create_version (api , update_instance , name , description )
206
209
0 commit comments