Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Only write the JSON file if there are any entries

Roland Geider6e8206036a2d
diff --git a/extras/scripts/filter-fixtures.py b/extras/scripts/filter-fixtures.py
index a1f7e776e..1e25f7dbf 100644
--- a/extras/scripts/filter-fixtures.py
+++ b/extras/scripts/filter-fixtures.py
@@ -30,8 +30,9 @@ def filter_dump(data, model_list, filename):
Helper function
'''
filter_data = [i for i in data if i['model'] in model_list]
- with open(filename, 'w') as outfile:
- json.dump(filter_data, outfile, indent=4)
+ if filter_data:
+ with open(filename, 'w') as outfile:
+ json.dump(filter_data, outfile, indent=4)
# This is a full dump of the DB
fixture = open('data.json')
@@ -84,3 +85,5 @@ filter_dump(data, ('config.gymconfig',), 'gym_config.json')
#
filter_dump(data, ('auth.group',), 'groups.json')
filter_dump(data, ('auth.user',), 'users.json')
+
+filter_dump(data, ('nutrition.logitem',), 'nutrition_diary.json')