@@ -30,11 +30,8 @@ def entry_manifest(request, pk):
30
30
data = open (f"db-sources/{ entry .basepath } /entries/{ pk } /game.json" ).read ()
31
31
json_data = json .loads (data )
32
32
33
- # Enrich the manifest with some values available only in the (postgres) database
34
- json_data ["devtoolinfo" ] = entry .devtoolinfo
35
- json_data ["basepath" ] = entry .basepath
36
- json_data ["baserepo" ] = entry .baserepo
37
- return JsonResponse (json_data )
33
+ merged_json_data = merge_manifest_data (json_data , entry )
34
+ return JsonResponse (merged_json_data )
38
35
39
36
40
37
def search_entries (request ):
@@ -130,12 +127,10 @@ def search_entries(request):
130
127
f"db-sources/{ entry .basepath } /entries/{ entry .slug } /game.json"
131
128
).read ()
132
129
json_data = json .loads (data )
133
- # Enrich the manifest with some values available only in the (postgres) database
134
- additional_json_data = {
135
- "basebath" : entry .basepath ,
136
- "firstadded_date" : entry .firstadded_date ,
137
- }
138
- json_entries .append ({** json_data , ** additional_json_data })
130
+
131
+ merged_json_data = merge_manifest_data (json_data , entry )
132
+
133
+ json_entries .append (merged_json_data )
139
134
140
135
# Prepare final JSON response
141
136
return JsonResponse (
@@ -191,6 +186,18 @@ def stats(request):
191
186
return JsonResponse (data )
192
187
193
188
189
+ def merge_manifest_data (data , entry ):
190
+ # Enrich the manifest with some values available only in the (postgres) database
191
+ additional_json_data = {
192
+ "basebath" : entry .basepath ,
193
+ "baserepo" : entry .baserepo ,
194
+ "firstadded_date" : entry .firstadded_date ,
195
+ "devtoolinfo" : entry .devtoolinfo ,
196
+ }
197
+
198
+ return {** data , ** additional_json_data }
199
+
200
+
194
201
# Utils
195
202
def sort_entries (entries , sort_key , direction = "asc" ):
196
203
# regardless what user has submitted, we lowercase the input
0 commit comments