Skip to content

Conversation

@rajulkumar
Copy link
Contributor

  • search_distributor api to get distributors on defined criteria
  • less_than(value) matcher to get objects with field value less than 'value'

Client has a method to search distributors as well.
It will return a Page with Distributor objects.
Added the field repo_type to Distributor object and
updated the schema to validate it.
less_than matcher returns the objects whose field values
is less than the matcher value.
Dates can also be compared with this matcher. It requires the dates
to be in a specific ISO format so as to identify it as a date and
generate the criteria accordingly.
Also, the fake client is updated for this new matcher.
Corresponding tests were added as well.
Added a new api and matcher. So incermented the
version number
@rajulkumar rajulkumar marked this pull request as ready for review August 29, 2019 18:42
@rajulkumar rajulkumar requested a review from rohanpm as a code owner August 29, 2019 18:42
Copy link
Contributor

@rohanpm rohanpm left a comment

Choose a reason for hiding this comment

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

I think when searching for fields stored in Pulp/mongo as a date, we should support passing a datetime value to the API; and we should avoid doing special things for string inputs which "look like" ISO8601 datetimes if at all possible.

@rajulkumar rajulkumar requested a review from rohanpm September 3, 2019 17:40
.. code-block:: python
# would match where last_publish is before "2019-08-27T00:00:00Z"
# date comparison requries a dateime.datetime object
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# date comparison requries a dateime.datetime object
# date comparison requires a datetime.datetime object


@visit(LessThanMatcher)
def match_less(matcher, field, obj):
# for datetime.dateime fields, obj_value is returned as pulp_value(iso format)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# for datetime.dateime fields, obj_value is returned as pulp_value(iso format)
# for datetime.datetime fields, obj_value is returned as pulp_value(iso format)

But actually, I don't think it is right to have the datetime conversion embedded directly next to the less-than comparison here. Is there a way to make it work for all of the comparisons like equals, in_ and so on?

Copy link
Contributor

Choose a reason for hiding this comment

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

I added bf15429 onto your PR which I believe should fix this problem in a better way, could you please have a look?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. This patch gets rid of that obj value vs matcher value inconsistencies.

rohanpm and others added 7 commits September 4, 2019 09:00
In the fake client, our logic for deciding whether we had found a
model field or a raw Pulp field was:

  using_model_field = mapped_field is not field

But that clearly doesn't work if the model field and the Pulp field
happen to have the same name.  This would lead to fields wrongly
using a Pulp conversion where none is required.

Up to now, it seems no fields hit the conditions where this mattered,
which is a field having:

- the same name on model and in Pulp
- and a (nontrivial) conversion required

With the addition of Distributor.last_publish as a datetime, this
bug now matters and must be fixed.

Instead of trying to reuse a single piece of data to mean multiple
things, let's just define the function as returning None if no
mapping occurred.
some values like datetime.datetime requires transaltion
to iso format. this translation was there for an object.
this patch extends that to translate the values in list
or dict type matcher values too.
distributor object has a field repo_id with the name of the
repository the distributor is attached to. the validation checks
if the distributor.repo_id is same as the repo.id of the repo
this distributor is being attached to else raises an exception.
@rajulkumar rajulkumar requested a review from rohanpm September 6, 2019 19:49
# hidden attribute for client attached to this object

@distributors.validator
def check_repo_id(self, _, value):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should also be named with _ to make it private API, this method isn't meant to be invoked directly by users.

Suggested change
def check_repo_id(self, _, value):
def _check_repo_id(self, _, value):

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd have committed this fix myself but it seems like I don't have permission (is the checkbox ticked to allow maintainers to edit this pull request?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is checked.

# hidden attribute for client attached to this object

@distributors.validator
def check_repo_id(self, _, value):
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 the last remaining issue I could see.

@rajulkumar rajulkumar requested a review from rohanpm September 9, 2019 13:14
@rohanpm rohanpm merged commit 2826e05 into release-engineering:master Sep 10, 2019
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