betodealmeida commented on a change in pull request #4821: Fix time 
granularity-related issues
URL: 
https://github.com/apache/incubator-superset/pull/4821#discussion_r182174130
 
 

 ##########
 File path: superset/models/core.py
 ##########
 @@ -786,7 +786,12 @@ def grains(self):
         return self.db_engine_spec.time_grains
 
     def grains_dict(self):
-        return {grain.duration: grain for grain in self.grains()}
+        """Allowing to lookup grain by either label or duration
+
+        For backward compatibility"""
+        d = {grain.duration: grain for grain in self.grains()}
+        d.update({grain.label: grain for grain in self.grains()})
 
 Review comment:
   How do the grains show up in the form? Do we have duplicates?

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


With regards,
Apache Git Services

Reply via email to