TireSwingSoftware / openassign-server

OpenAssign server intended for use by a separate client via RPC
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

filter with "greater_than" using dates #77

Closed mhrivnak closed 12 years ago

mhrivnak commented 12 years ago

Currently, the only way to use dates in a get_filtered() call is by defining a date range. We also need to use dates with "greater_than", specifically so we can get all BlackoutPeriod objects that occur in the future.

While we're at it, it will probably be trivial to implement this for "less_than" as well.

mhrivnak commented 12 years ago

This needs a test. As much as it pains me to commit without a test and abandon this issue, I must work on UI code as much as possible right now. However, we definitely won't commit a release to the master branch until all issues like this have received satisfactory tests.

jc0n commented 12 years ago

Is there any particular reason why this is not applied to exact, greater_than_or_equal and less_than_or_equal as well?

jc0n commented 12 years ago

The date created in handle_endpoint also needs to have tzinfo set to properly compare the dates. I'll take care of it.

As a side note: Is there any reason why this isnt done always in pr_time.iso8601_to_datetime?

mhrivnak commented 12 years ago

No reason at all. Feel free to add them. I was just adding the ones I needed for the UI.

On Sat, Jan 28, 2012 at 7:31 PM, John O'Connor reply@reply.github.com wrote:

Is there any particular reason why this is not applied to greater_than_or_equal and less_than_or_equal as well?

jc0n commented 12 years ago

Might as well for the sake of completion.

mhrivnak commented 12 years ago

I think that when tzinfo is None, that means UTC. The final return value is a product of calling datetime.utcfromtimestamp(), which as you can imagine, is designed to always return a datetime in UTC.

https://github.com/TireSwingSoftware/openassign-server/blob/0764f7b0197f45e2c86a48777c9c5daab9a4fc35/pr_services/pr_time.py#L34

http://docs.python.org/library/datetime.html#datetime.datetime.utcfromtimestamp

On Sat, Jan 28, 2012 at 7:47 PM, John O'Connor reply@reply.github.com wrote:

The date created in handle_endpoint also needs to have tzinfo set to properly compare the dates. I'll take care of it.

As a side note: Is there any reason why this isnt done always in pr_time.iso8601_to_datetime?

jc0n commented 12 years ago

Right but the problem occurs when compared to dates with tzinfo=pr_time.UTC(). If you want to see what I mean checkout issue/77 and run the pr_services.TestGetFiltered with and without commit dc94678681797da5ee9a4001ad8940faec535d94 present.

jc0n commented 12 years ago

I created a separate issue #90 for the date consistency issue.

For now the date created in the filter uses the pr_time.UTC class which is sufficient for this issue.

This is now merged into dev.