codeant-ai-for-open-source[bot] commented on code in PR #41550:
URL: https://github.com/apache/superset/pull/41550#discussion_r3691317056


##########
superset/views/filters.py:
##########
@@ -292,6 +314,37 @@ def _mark_response_for_deleted_at_augmentation() -> None:
         setattr(g, AUGMENT_RESPONSE_WITH_DELETED_AT, True)
 
 
+class BaseDeletedRecencyFilter(BaseFilter):  # pylint: 
disable=too-few-public-methods
+    """Keep rows archived within the last *value* days, by the server's clock.
+
+    The archive UI's time-range presets used to send an absolute cutoff
+    computed client-side in UTC. ``deleted_at`` is stamped with the server's
+    naive-local ``datetime.now()``, so on any non-UTC deployment those
+    cutoffs were shifted by the server offset -- and because the cutoff was
+    frozen when the page mounted, a long-lived tab drifted further. Taking a
+    day count and resolving it here, on the clock that stamped the column,
+    removes both failure modes and lets the client keep stable, shareable
+    filter values.
+
+    Subclasses set ``arg_name`` (e.g. ``"chart_deleted_recency"``).
+    """
+
+    name = lazy_gettext("Archived within")
+
+    def apply(self, query: Query, value: Any) -> Query:
+        try:
+            days = int(value)
+        except (TypeError, ValueError):
+            # Filter values arrive from the URL; refusing loudly would turn a
+            # mangled query string into a 500. An unfiltered list is the same
+            # answer every other malformed FAB filter value produces.
+            return query
+        if days <= 0:
+            return query
+        cutoff = datetime.now() - timedelta(days=days)
+        return query.filter(self.model.deleted_at > cutoff)

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag the recency filter for omitting the soft-delete visibility 
bypass; archived visibility and restore-audience scoping must be established by 
the deleted_state filter, and recency should compose with it rather than imply 
it.
   
   **Applied to:**
     - `superset/views/filters.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



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