Skip to content

Scoped object search#373

Draft
jsh2134 wants to merge 3 commits intomasterfrom
scoped-object-search
Draft

Scoped object search#373
jsh2134 wants to merge 3 commits intomasterfrom
scoped-object-search

Conversation

@jsh2134
Copy link
Contributor

@jsh2134 jsh2134 commented Oct 20, 2020

Search from within the folders/files/dataset shortcuts in the same way as Object.search, but scope it to the shortcut in both location and object type

The following searches can be replaced with one nice command

folder.search("foobar AND type:file", parent_object_id=folder.id)
folder.search("foobar", object_type="file", parent_object_id=folder.id)
folder.files(query="foobar")

become

folder.files("foobar")

# TODO
params['ancestor_id'] = self.id
params['limit'] = 1000
return super(Object, self).search(query, **params)
Copy link
Contributor Author

@jsh2134 jsh2134 Dec 1, 2020

Choose a reason for hiding this comment

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

I believe I left this TODO in here in order to determine if there should be a recursive option. Should the user be able to get anything in this folder, or just depth=0 objects.

and/or ancestor_id needs to be replaced by parent_object_id (although the server may handle this)

This PR needs tests

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets keep it ancestor_id so that it is recursive. Users can pass depth=0 if they want, and we will document this.

@davecap davecap marked this pull request as draft January 8, 2021 14:59
return self.objects(query=query, **params)

def search(self, query='', **params):
query = query or params.pop('query', '')
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary

# TODO
params['ancestor_id'] = self.id
params['limit'] = 1000
return super(Object, self).search(query, **params)
Copy link
Contributor

Choose a reason for hiding this comment

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

Object.search(), super not necessary because search is a classmethod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants