Fokko commented on a change in pull request #4871: [AIRFLOW-3844][WIP] Remove 
DagBag from /landing_times.
URL: https://github.com/apache/airflow/pull/4871#discussion_r264040320
 
 

 ##########
 File path: airflow/models/__init__.py
 ##########
 @@ -3120,36 +3272,34 @@ def __exit__(self, _type, _value, _tb):
 
     # /Context Manager ----------------------------------------------
 
+    @property
+    def model(self):
+        if self._model is None:
+            dag_model = session.query(DagModel).filter(
+                DagModel.dag_id == self.dag_id).first()
+            if not orm_dag:
+                self.log.info("Creating ORM DAG model for %s", self.dag_id)
+                dag_model = DagModel(dag_id=self.dag_id)
+            self._model = dag_model
+        return dag_model
+
     def get_default_view(self):
         """This is only there for backward compatible jinja2 templates"""
         if self._default_view is None:
             return configuration.conf.get('webserver', 
'dag_default_view').lower()
         else:
             return self._default_view
 
-    def date_range(self, start_date, num=None, end_date=timezone.utcnow()):
-        if num:
-            end_date = None
-        return utils_date_range(
-            start_date=start_date, end_date=end_date,
-            num=num, delta=self._schedule_interval)
+    def date_range(self, start_date, num=None, end_date=utcnow()):
+        return self.model.date_range(start_date, num=num, end_date=end_date)
 
     def is_fixed_time_schedule(self):
 
 Review comment:
   If the function only calls another function, we should consider removing the 
intermediate function.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

Reply via email to