ashb commented on a change in pull request #3743: [AIRFLOW-2799] Filtering UI
objects by datetime is broken
URL: https://github.com/apache/incubator-airflow/pull/3743#discussion_r225848094
##########
File path: airflow/www/utils.py
##########
@@ -428,7 +437,26 @@ def __call__(self, field, **kwargs):
return wtforms.widgets.core.HTMLString(html)
+# This class simply does the same as the base class, but returns
+# an aware datetime object (should be in UTC)
+class BaseUTCDateTimeFilter(BaseDateTimeFilter):
+ def clean(self, value):
+ return make_aware(datetime.datetime.strptime(value, '%Y-%m-%d
%H:%M:%S'))
+
+class UTCDateTimeEqualFilter(DateTimeEqualFilter, BaseUTCDateTimeFilter): pass
+class UTCDateTimeNotEqualFilter(DateTimeNotEqualFilter,
BaseUTCDateTimeFilter): pass
+class UTCDateTimeGreaterFilter(DateTimeGreaterFilter, BaseUTCDateTimeFilter):
pass
+class UTCDateTimeSmallerFilter(DateTimeSmallerFilter, BaseUTCDateTimeFilter):
pass
+class UTCDateTimeBetweenFilter(DateTimeBetweenFilter, BaseUTCDateTimeFilter):
pass
+class UTCDateTimeNotBetweenFilter(DateTimeNotBetweenFilter,
BaseUTCDateTimeFilter): pass
+
+
class UtcFilterConverter(FilterConverter):
+ utcdatetime_filters = (UTCDateTimeEqualFilter, UTCDateTimeNotEqualFilter,
+ UTCDateTimeGreaterFilter, UTCDateTimeSmallerFilter,
+ UTCDateTimeBetweenFilter,
UTCDateTimeNotBetweenFilter,
+ FilterEmpty)
+
@filters.convert('utcdatetime')
def conv_utcdatetime(self, column, name, **kwargs):
- return self.conv_datetime(column, name, **kwargs)
+ return [f(column, name, **kwargs) for f in self.utcdatetime_filters]
Review comment:
I was wrong on this comment btw.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services