Skip to content

Commit

Permalink
[#1886] Change default of tag_show include_datasets to False, like in #…
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Jun 12, 2015
1 parent 72d1707 commit 90d0ddd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
9 changes: 4 additions & 5 deletions CHANGELOG.rst
Expand Up @@ -30,11 +30,10 @@ Changes and deprecations
* Add middleware that cleans up the response string after it has been
served, stabilizes memory usage for large requests #1847

* The ``vocabulary_show`` API call no longer returns the ``packages`` key -
i.e. datasets that use the vocabulary. ``tag_show`` API call now supports
vocabularies, so that you can get the datasets using a vocabulary tag. In
addition ``tag_show`` has an option not ``include_datasets``, which gives
better performance. (#1886)
* The ``vocabulary_show`` and ``tag_show`` API calls no longer returns the
``packages`` key - i.e. datasets that use the vocabulary or tag.
``tag_show`` now has an ``include_datasets`` option and has been extended
to work with vocabulary tags. (#1886)


v2.3 2015-03-04
Expand Down
4 changes: 2 additions & 2 deletions ckan/logic/action/get.py
Expand Up @@ -1280,7 +1280,7 @@ def tag_show(context, data_dict):
:param include_datasets: include a list of the tag's datasets. (Up to a
limit of 1000 - for more flexibility, use package_search - see
:py:func:`package_search` for an example.)
(optional, default: ``True``)
(optional, default: ``False``)
:type include_datasets: bool
:returns: the details of the tag, including a list of all of the tag's
Expand All @@ -1290,7 +1290,7 @@ def tag_show(context, data_dict):

model = context['model']
id = _get_or_bust(data_dict, 'id')
include_datasets = asbool(data_dict.get('include_datasets', True))
include_datasets = asbool(data_dict.get('include_datasets', False))

tag = model.Tag.get(id, vocab_id_or_name=data_dict.get('vocabulary_id'))
context['tag'] = tag
Expand Down
22 changes: 12 additions & 10 deletions ckan/tests/logic/action/test_get.py
Expand Up @@ -1470,6 +1470,14 @@ def test_tag_show_for_free_tag(self):
eq(tag_shown['display_name'], 'acid-rain')
eq(tag_shown['id'], tag_in_dataset['id'])
eq(tag_shown['vocabulary_id'], None)
assert 'packages' not in tag_shown

def test_tag_show_with_datasets(self):
dataset = factories.Dataset(tags=[{'name': 'acid-rain'}])

tag_shown = helpers.call_action('tag_show', id='acid-rain',
include_datasets=True)

eq([d['name'] for d in tag_shown['packages']], [dataset['name']])

def test_tag_show_not_found(self):
Expand All @@ -1482,7 +1490,8 @@ def test_tag_show_for_flexible_tag(self):
# and foreign characters in its name
dataset = factories.Dataset(tags=[{'name': u'Flexible. \u30a1'}])

tag_shown = helpers.call_action('tag_show', id=u'Flexible. \u30a1')
tag_shown = helpers.call_action('tag_show', id=u'Flexible. \u30a1',
include_datasets=True)

eq(tag_shown['name'], u'Flexible. \u30a1')
eq(tag_shown['display_name'], u'Flexible. \u30a1')
Expand All @@ -1495,22 +1504,15 @@ def test_tag_show_for_vocab_tag(self):
tag_in_dataset = dataset['tags'][0]

tag_shown = helpers.call_action('tag_show', id='acid-rain',
vocabulary_id=vocab['id'])
vocabulary_id=vocab['id'],
include_datasets=True)

eq(tag_shown['name'], 'acid-rain')
eq(tag_shown['display_name'], 'acid-rain')
eq(tag_shown['id'], tag_in_dataset['id'])
eq(tag_shown['vocabulary_id'], vocab['id'])
eq([d['name'] for d in tag_shown['packages']], [dataset['name']])

def test_tag_show_without_datasets(self):
factories.Dataset(tags=[{'name': 'acid-rain'}])

tag_shown = helpers.call_action('tag_show', id='acid-rain',
include_datasets=False)

assert 'packages' not in tag_shown


class TestTagList(helpers.FunctionalTestBase):

Expand Down

0 comments on commit 90d0ddd

Please sign in to comment.