michael-s-molina commented on code in PR #33626:
URL: https://github.com/apache/superset/pull/33626#discussion_r2123503618


##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -1188,6 +1190,10 @@ def test_update_dataset_create_column_and_metric(self):
             metric.pop("type_generic", None)
 
         data["result"]["metrics"].append(new_metric_data)
+
+        # Sleep to ensure that the changed_on is updated

Review Comment:
   Optional: You can use `freezegun` to control time and make tests more 
accurate and efficient.
   
   ```
   from freezegun import freeze_time
   
   with freeze_time("2021-01-01T00:00:00Z"):
      ...
   ```



##########
superset/daos/dataset.py:
##########
@@ -184,15 +184,21 @@ def update(
         """
 
         if item and attributes:
+            force_update: bool = False
             if "columns" in attributes:
                 cls.update_columns(
                     item,
                     attributes.pop("columns"),
                     override_columns=bool(attributes.get("override_columns")),
                 )
+                force_update = True
 
             if "metrics" in attributes:
                 cls.update_metrics(item, attributes.pop("metrics"))
+                force_update = True
+
+            if force_update:
+                attributes["changed_on"] = datetime.now(tz=timezone.utc)

Review Comment:
   Thanks 🙏🏼 



##########
superset/connectors/sqla/models.py:
##########
@@ -2072,8 +2056,6 @@ def load_database(self: SqlaTable) -> None:
 sa.event.listen(SqlaTable, "before_update", SqlaTable.before_update)
 sa.event.listen(SqlaTable, "after_insert", SqlaTable.after_insert)
 sa.event.listen(SqlaTable, "after_delete", SqlaTable.after_delete)
-sa.event.listen(SqlMetric, "after_update", SqlaTable.update_column)

Review Comment:
   @Vitor-Avila The previous event-based implementation was triggered for 
changes from any source. This means that any time `SqlMetric` or `TableColumn` 
was updated, from any part of the code, the timestamp was updated. Did we check 
to see if these models are updated outside the DAO?



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to