Skip to content

Commit

Permalink
simplify check for moderation status
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-float-on committed Mar 14, 2024
1 parent 6900df8 commit 31a7f6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
4 changes: 3 additions & 1 deletion dbtmetabase/_exposures.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ def extract_exposures(
for item in self.metabase.get_collection_items(
uid=collection["id"],
models=("card", "dashboard"),
exclude_unverified=exclude_unverified,
):
if exclude_unverified and item.get("moderated_status") != "verified":
_logger.debug("Skipping unverified item '%s'", item["id"])
continue
depends = set()
native_query = ""
header = ""
Expand Down
11 changes: 0 additions & 11 deletions dbtmetabase/metabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def get_collection_items(
self,
uid: str,
models: Sequence[str],
exclude_unverified: bool = False,
) -> Sequence[Mapping]:
"""Retrieves collection items of specific types (e.g. card, dashboard, collection)."""
results = list(
Expand All @@ -141,16 +140,6 @@ def get_collection_items(
params={"models": models},
)
)
if exclude_unverified:
verified_results = list(
self._api(
method="get",
path=f"/api/search/",
params={"models": models, "verified": True},
)
)
verified_ids = [y['id'] for y in verified_results]
results = [x for x in results if x['id'] in verified_ids]
results = list(filter(lambda x: x["model"] in models, results))
return results

Expand Down

0 comments on commit 31a7f6a

Please sign in to comment.