#60 Filter out resigned offer subscription.

Merged
jocelyn merged 2 commits from opi/offer-subscription-count into FFDN/master 8 years ago
opi commented 8 years ago
Fix https://code.ffdn.org/FFDN/coin/pulls/58#issuecomment-171
jocelyn commented 8 years ago
Owner
.filter(Q(offersubscription__resign_date__gt=datetime.date.today) | Q(offersubscription__resign_date__isnull=True))\
  • Why datetime.date.today instead of datetime.date.today() ; does it even works (genuine question, I haven't tested) ?

  • To make this command really useful ; it would require IMHO to offer a date argument to specify at which date we want that information (instead of always using today()).

``` .filter(Q(offersubscription__resign_date__gt=datetime.date.today) | Q(offersubscription__resign_date__isnull=True))\ ``` - Why `datetime.date.today` instead of `datetime.date.today()` ; does it even works (genuine question, I haven't tested) ? - To make this command really useful ; it would require IMHO to offer a *date* argument to specify at which date we want that information (instead of always using `today()`).
opi commented 8 years ago
Owner

Why datetime.date.today instead of datetime.date.today() ; does it even works ?

Because I'm the copy/paste master ! https://code.ffdn.org/FFDN/coin/src/master/coin/offers/offersubscription_filter.py#L21 (and yes, it works!)

To make this command really useful ; it would require IMHO to offer a date argument to > specify at which date we want that information (instead of always using today()).

Interesting indeed. I'll try to add this feature.

> Why datetime.date.today instead of datetime.date.today() ; does it even works ? Because I'm the copy/paste master ! https://code.ffdn.org/FFDN/coin/src/master/coin/offers/offersubscription_filter.py#L21 (and yes, it works!) > To make this command really useful ; it would require IMHO to offer a date argument to > specify at which date we want that information (instead of always using today()). Interesting indeed. I'll try to add this feature.
opi commented 8 years ago
Owner

date argument added in bc0dd85e33

date argument added in bc0dd85e3324e01a7aab9496b824dcd2424c4a4f
jocelyn commented 8 years ago
Owner

Cool :-)

There is still a logical issue :

  • (offersubscription__resign_date__isnull=True) is not sufficient to tell that a subscription is running at a given date.

  • If you want to move that logic out of the command file, you could create a OfferSubscriptionQuerySet with a running(date) method in coin/offers/models.py that you then call from your command. That's not a blocker for this PR ; just a bare suggestion/lead.

An example queryset (set as "objects" var in the model itself) can be found here : https://code.ffdn.org/jocelyn/transparency/src/master/costs/models.py#L180-L194

See also https://docs.djangoproject.com/en/1.9/topics/db/managers/#creating-a-manager-with-queryset-methods

Cool :-) There is still a logical issue : - `(offersubscription__resign_date__isnull=True)` is not sufficient to tell that a subscription is running at a given date. - If you want to move that logic out of the command file, you could create a `OfferSubscriptionQuerySet` with a `running(date)` method in *coin/offers/models.py* that you then call from your command. That's not a blocker for this PR ; just a bare suggestion/lead. An example queryset (set as "objects" var in the model itself) can be found here : https://code.ffdn.org/jocelyn/transparency/src/master/costs/models.py#L180-L194 See also https://docs.djangoproject.com/en/1.9/topics/db/managers/#creating-a-manager-with-queryset-methods
opi commented 8 years ago
Owner

(offersubscription__resign_date__isnull=True) is not sufficient to tell that a subscription is running at a given date.

The full query is offersubscription__subscription_date__lte=date & (offersubscription__resign_date__gt=date | offersubscription__resign_date__isnull=True, so logically 'subscribed' AND 'not resigned'

I'm not seeing any logical issue there, but maybe I got a personnal coffee issue ;)

> `(offersubscription__resign_date__isnull=True)` is not sufficient to tell that a subscription is running at a given date. The full query is `offersubscription__subscription_date__lte=date & (offersubscription__resign_date__gt=date | offersubscription__resign_date__isnull=True`, so logically 'subscribed' AND 'not resigned' I'm not seeing any logical issue there, but maybe I got a personnal coffee issue ;)
jocelyn commented 8 years ago
Owner

Missed a parenthesis (so coffee issue was on my side) ; nevermind, merging :-)

Missed a parenthesis (so coffee issue was on my side) ; nevermind, merging :-)
This pull request has been merged successfully!
Sign in to join this conversation.
No Milestone
No assignee
2 Participants
Loading...
Cancel
Save
There is no content yet.