Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken submission tags #690

Open
joshuaberetta opened this issue Mar 12, 2021 · 4 comments
Open

Broken submission tags #690

joshuaberetta opened this issue Mar 12, 2021 · 4 comments
Assignees
Labels

Comments

@joshuaberetta
Copy link
Member

joshuaberetta commented Mar 12, 2021

The /labels endpoint expects the add_tags_to_instance method to return True or False to update the response status, but the method returns nothing:

if request.method == 'POST':
if add_tags_to_instance(request, instance):
http_status = status.HTTP_201_CREATED

def add_tags_to_instance(request, instance):
class TagForm(forms.Form):
tags = TagField()
form = TagForm(request.data)
if form.is_valid():
tags = form.cleaned_data.get('tags', None)
if tags:
for tag in tags:
instance.tags.add(tag)
instance.save()

The add_tags_to_instance method should also call instance.parsed_instance.save() after instance.save() to update Mongo and therefore have the API and exports handle the tags correctly.

Tests for the labels endpoint should also be added.

@jnm
Copy link
Member

jnm commented Mar 15, 2021

I think we should check the database to see if any of these submission tags exist, and if none do, then we should remove the feature altogether

@joshuaberetta
Copy link
Member Author

They could be present in the database as one could still post tags, but it just wasn't synced and displayed correctly — and the response message was always 400 😂

@jnm
Copy link
Member

jnm commented Mar 16, 2021

Ha. This is HHI production:

>>> ct = ContentType.objects.get_for_model(Instance)
>>> tii = TaggedItem.objects.filter(content_type=ct)
>>> tii.count()
298
>>> pprint.pprint(list(tii.values('tag__name').distinct()))
[{'tag__name': u'foo'},
 {'tag__name': u"[u'a6FYdeSJBhH95R2chU6xPu'"},
 {'tag__name': u'nutval'},
 {'tag__name': u'a6499tkZSA3aRrmoUyCX5o'},
 {'tag__name': u'test'},
 {'tag__name': u'tag1'},
 {'tag__name': u'test_tag_ha'},
 {'tag__name': u'bns'},
 {'tag__name': u"u'congo']"},
 {'tag__name': u'done'},
 {'tag__name': u"[u'peche'"},
 {'tag__name': u'auqBASwJMLvkqtAJnZ8SXx'},
 {'tag__name': u'bar'},
 {'tag__name': u'tag2'},
 {'tag__name': u'testing'},
 {'tag__name': u"u'bns']"},
 {'tag__name': u'fighters'},
 {'tag__name': u'approved_record'},
 {'tag__name': u'a6FYdeSJBhH95R2chU6xPu'},
 {'tag__name': u"[u'foo']"}]
>>> 

I think OCHA is going to have to do better for us to keep this feature. When you say "it just wasn't synced and displayed correctly", was it possible for people to see the tags they'd assigned to submissions at all? If they had no way of accessing them, then they might as well have not existed.

@joshuaberetta
Copy link
Member Author

My experience with the buggy nature of the tags:

  • Try adding a tag to a submission through the api -> 400 status (but actually is saved), array of all tags returned in body
  • View submissions at the /data endpoint -> may or may not see only one tag (seems like the first one)
    As I mentioned in the description, when adding instance.parsed_instance.save() under instance.save() it solves the sync issue and all tags can be viewed correctly.

Looking at that list of tags you shared, I can see that several of them are from me testing the production endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants