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

Add language filter to sync-ingredients management command. #1875

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

navyjosh
Copy link

Proposed Changes

  • Allow user to specify a language when syncing ingredients
  • example: python manage.py sync-ingredients --languages=en,fr,es

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
    • wger.nutrition.tests.test_xync.TestSyncMethods has been slightly modified to ensure uri was called with proper filter.
  • Added yourself to AUTHORS.rst

Other questions

  • Do users need to run some commmands in their local instances due to this PR
    (e.g. database migration)? No

mock_request.assert_called_with(
'https://wger.de/api/v2/ingredient/?limit=999',
'https://wger.de/api/v2/ingredient/?limit=999&language=2',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a new simple test here, something like def test_ingredient_sync_languages that only checks that the correct URL is called

url = make_uri(
INGREDIENTS_ENDPOINT,
server_url=remote_url,
query={'limit': API_MAX_ITEMS, 'language': language_id},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just allow passing all languages at once, seems easier that way. For this we just need to add 'in' to IngredientFilterSet, like in 'id'. Then we can do query={'limit': API_MAX_ITEMS, 'language__in': ','.join([languages])} (this also works if we only pass one)

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

Successfully merging this pull request may close these issues.

2 participants