You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2018/08/15 09:06:58 UTC

[GitHub] ashb commented on a change in pull request #3743: [AIRFLOW-2799] Filtering UI objects by datetime is broken

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_r210211080
 
 

 ##########
 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:
   These should all probably live in airflow/utils/sqlalchemy.py

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services