betodealmeida commented on a change in pull request #5380: Add time grain 
blacklist and addons to config.py
URL: 
https://github.com/apache/incubator-superset/pull/5380#discussion_r204507706
 
 

 ##########
 File path: superset/db_engine_specs.py
 ##########
 @@ -52,6 +52,35 @@
 
 Grain = namedtuple('Grain', 'name label function duration')
 
+builtin_time_grains = {
+    None: 'Time Column',
+    'PT1S': 'second',
+    'PT1M': 'minute',
+    'PT5M': '5 minute',
+    'PT10M': '10 minute',
+    'PT15M': '15 minute',
+    'PT0.5H': 'half hour',
+    'PT1H': 'hour',
+    'P1D': 'day',
+    'P1W': 'week',
+    'P1M': 'month',
+    'P0.25Y': 'quarter',
+    'P1Y': 'year',
+    '1969-12-28T00:00:00Z/P1W': 'week_start_sunday',
+    '1969-12-29T00:00:00Z/P1W': 'week_start_monday',
+    'P1W/1970-01-03T00:00:00Z': 'week_ending_saturday',
+}
+
+
+def _create_time_grains_tuple(time_grains, time_grain_functions, blacklist):
+    ret_list = list()
+    blacklist = blacklist if blacklist else []
+    for duration, func in time_grain_functions.items():
+        if duration not in blacklist:
+            name = time_grains.get(duration, None)
 
 Review comment:
   Nit: `{}.get` already returns `None` when the key is not present, so this 
can be written simply as:
   
   ```python
   name = time_grains.get(duration)
   ```

----------------------------------------------------------------
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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to