Vitor-Avila commented on code in PR #32585:
URL: https://github.com/apache/superset/pull/32585#discussion_r1989195271


##########
superset/tasks/slack.py:
##########
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import logging
+
+from superset.extensions import celery_app
+from superset.utils.slack import get_channels
+
+logger = logging.getLogger(__name__)
+
+
+@celery_app.task(name="slack.cache_channels")
+def cache_channels() -> None:
+    get_channels(force=True)

Review Comment:
   Could we enforce calling it with a `cache_timeout` as well? Just to prevent 
creating cache items that don't have an expiration (since it's a scheduled task 
it would always refresh on schedule, but there's an edge case of a user 
disabling the task and then it would be there until someone refreshes through 
the UI which has a `cache_timeout`).
   
   I was actually wondering if we should have a new config like 
`SLACK_CACHE_TIMEOUT` (since this is hardcoded in the code, keeping it in 
`config.py` might make more sense). This was supposed to be part of my PR, but 
just thought about it after having it merged so was planning to do a follow up 
in the future. If we have a config, we could use it here + in the API config.



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