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()`).
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.
(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.
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
(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 ;)
Fix https://code.ffdn.org/FFDN/coin/pulls/58#issuecomment-171
.filter(Q(offersubscription__resign_date__gt=datetime.date.today) | Q(offersubscription__resign_date__isnull=True))\
Why
datetime.date.today
instead ofdatetime.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()
).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!)
Interesting indeed. I'll try to add this feature.
date argument added in
bc0dd85e33
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 arunning(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
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 ;)
Missed a parenthesis (so coffee issue was on my side) ; nevermind, merging :-)