Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

global: item revision endpoint #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mvesper
Copy link
Contributor

@mvesper mvesper commented Dec 21, 2016

  • Adds the endpoint configuration for Item.find_by_holding.

@mvesper
Copy link
Contributor Author

mvesper commented Dec 21, 2016

Things to consider:

  • If we just create a Search class, we kinda have to mimick some of the elasticsearch_dsl behavior.
  • Do we want to create our own queryparser for this? Right now I just deconstruct elasticsearch_dsl objects.
  • The CIRCULATION_REST_ENDPOINT config is a bit 'dirty', since I defined a pid_type that doesn't exist and that I don't need. But maybe there is a neither way to go for it.

@mvesper mvesper force-pushed the gim_third_revision_endpoint branch 2 times, most recently from c7e60fb to adbc09f Compare December 21, 2016 14:44
},
'crcrev': {
'default_endpoint_prefix': True,
'pid_type': 'crcrev',
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have a new pid_type or can you use the 'crcitm'?

@mvesper mvesper force-pushed the gim_third_revision_endpoint branch 3 times, most recently from 695f0da to c5b368d Compare January 10, 2017 13:22
Copy link

@david-caro david-caro left a comment

Choose a reason for hiding this comment

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

Looks ok, have a couple of 'questions' there though.

output = json.loads(
subprocess.check_output(cmd, shell=True).decode('utf-8')
)
assert output and 'hits' in output and 'hits' in output['hits']

Choose a reason for hiding this comment

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

Shouldn't you check the amount of hits? (not sure if it's relevant though, maybe just the fact that the hits key is there means that there have been some)

Choose a reason for hiding this comment

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

Maybe even compare it to the expected dict like you do in the other test:

assert output == {
    'hits': {
        'hits': ...
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, you are correct :). But in order to make this happen I'd also have to change the examples.app:items to create better fixtures. Since this PR grew quite a little already, maybe we can do this later.
Right now we just check that the endpoint is there.

Choose a reason for hiding this comment

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

Sure, just make sure to open an issue on it just to not forget about it.

item_revision_search = ItemRevisionSearch()

assert item_revision_search == item_revision_search[0]
assert item_revision_search == item_revision_search.params()

Choose a reason for hiding this comment

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

What is this black magic?! Xd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our search classes subclass elasticsearch_dsl.Search (at least invenio_search.RecordsSearch does) and this class has the methods __getitem__ and params that I had to mock for the desired functionality.
Those functions perform some changes (__getitem__ for example uses slicing for pagination) and then return themselves :)

@egabancho
Copy link

LGTM


from invenio_search import RecordsSearch
from invenio_circulation.api import Item
Copy link
Contributor

Choose a reason for hiding this comment

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

@mvesper is the isort enabled in /run-tests.sh?

Normally, we use relative imports for current package, hence from .api import Item. In anycase there should be an empty line before block of imports from current language. Just check it with isort invenio_circulation/search.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isort is on and I changed it to relative import :)

@david-caro
Copy link

Looks good to me :)

@mvesper mvesper changed the title WIP global: item revision endpoint global: item revision endpoint Jan 16, 2017
Copy link
Contributor

@jirikuncar jirikuncar left a comment

Choose a reason for hiding this comment

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

LGTM

--
Since it is already 2017, can you update copyrights in files you have touched?

@mvesper
Copy link
Contributor Author

mvesper commented Jan 16, 2017

@jirikuncar Changed the copyrights :)

@jirikuncar
Copy link
Contributor

@mvesper you should just add 2017 and keep 2016.

* Adds the endpoint configuration for `Item.find_by_holding`.

Signed-off-by: Martin Vesper <[email protected]>
@mvesper
Copy link
Contributor Author

mvesper commented Jan 16, 2017

@jirikuncar x) fixed

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

Successfully merging this pull request may close these issues.

4 participants