Skip to content

Commit

Permalink
Merge pull request #3 from LCOGT/feature/deduplicating-data-session-i…
Browse files Browse the repository at this point in the history
…nput-data

update overwrite to remove duplicate data
  • Loading branch information
LTDakin authored Feb 28, 2024
2 parents 4051d56 + fa8a623 commit ce22979
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions datalab/datalab_session/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,16 @@ class DataSessionSerializer(serializers.ModelSerializer):
class Meta:
model = DataSession
fields = '__all__'

def update(self, instance, validated_data):
input_data = validated_data.get('input_data', [])

# Check for duplicates
existing_input_data = instance.input_data
new_input_data = []
for item in input_data:
if item not in existing_input_data:
new_input_data.append(item)

validated_data['input_data'] = existing_input_data + new_input_data
return super().update(instance, validated_data)

0 comments on commit ce22979

Please sign in to comment.