Skip to content

Commit a7a04ab

Browse files
authored
Merge pull request #50 from biocompute-objects/fix-only-most-recent-api-object-token
fixed returning only the requested entries
2 parents 542197f + 8cd5cdd commit a7a04ab

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bco_api/api/scripts/method_specific/POST_api_objects_drafts_token.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ def POST_api_objects_drafts_token(
164164
# import pdb; pdb.set_trace()
165165

166166
published = bco.objects.filter(state='PUBLISHED').values()
167-
unique_published = []
167+
# unique_published = []
168+
unique_published = set()
168169

169170
# E.g.
170171
# published[0]["contents"]["object_id"] = 'http://127.0.0.1:8000/BCO_000010/1.0'
@@ -202,9 +203,14 @@ def POST_api_objects_drafts_token(
202203
"bco_object": p
203204
}
204205
for key, value in bcos.items():
205-
unique_published.append(value["bco_object"])
206+
# unique_published.append(value["bco_object"])
207+
# import pdb;pdb.set_trace()
208+
unique_published.add(value["bco_object"]["id"])
209+
210+
# result_list = chain(user_objects.intersection(prefix_objects).values(*return_values), unique_published(*return_values))
211+
unique_published = bco.objects.filter(id__in = unique_published)
212+
result_list = chain(user_objects.intersection(unique_published).values(*return_values), prefix_objects.values(*return_values))
206213

207-
result_list = chain(user_objects.intersection(prefix_objects).values(*return_values), unique_published)
208214

209215
return Response(
210216
data=result_list,

0 commit comments

Comments
 (0)