etr2460 commented on a change in pull request #10630:
URL:
https://github.com/apache/incubator-superset/pull/10630#discussion_r473192818
##########
File path: superset/connectors/sqla/models.py
##########
@@ -391,6 +394,38 @@ def lookup_obj(lookup_metric: SqlMetric) -> SqlMetric:
return import_datasource.import_simple_obj(db.session, i_metric,
lookup_obj)
+ @property
+ def is_certified(self) -> bool:
+ try:
+ extra_object = json.loads(self.extra)
+ return bool(extra_object.get("certification", False))
+ except (TypeError, json.JSONDecodeError):
+ return False
+
+ @property
+ def certified_by(self) -> Optional[str]:
+ try:
+ extra_object = json.loads(self.extra)
+ return extra_object.get("certification", {}).get("certified_by",
None)
+ except (TypeError, json.JSONDecodeError):
+ return None
+
+ @property
+ def certification_details(self) -> Optional[str]:
+ try:
+ extra_object = json.loads(self.extra)
+ return extra_object.get("certification", {}).get("details", None)
+ except (TypeError, json.JSONDecodeError):
+ return None
+
+ @property
+ def data(self) -> Dict[str, Any]:
+ attrs = ("is_certified", "certified_by", "certification_details")
+ attr_dict = {s: getattr(self, s) for s in attrs}
Review comment:
There's a decent bit of magic in the CRUD JS code, so I think keeping as
a flat dict is the easiest for now. I'm going to leave this as is
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]