dpgaspar commented on a change in pull request #13828:
URL: https://github.com/apache/superset/pull/13828#discussion_r608495681
##########
File path: superset/reports/commands/execute.py
##########
@@ -190,23 +202,50 @@ def _get_screenshot(self) -> bytes:
raise ReportScheduleScreenshotFailedError()
return image_data
+ def _get_csv_data(self) -> bytes:
+ if self._report_schedule.chart:
+ url = self._get_url(csv=True)
+ auth_cookies =
machine_auth_provider_factory.instance.get_auth_cookies(
+ self._get_screenshot_user()
+ )
+ try:
+ csv_data = get_chart_csv_data(url, auth_cookies)
+ except SoftTimeLimitExceeded:
+ raise ReportScheduleScreenshotTimeout()
+ except Exception as ex:
+ raise ReportScheduleCsvFailedError(f"Failed generating csv
{str(ex)}")
+ if not csv_data:
Review comment:
If the query returns no results, does the CSV always includes the
columns? or will it be considered an error?
##########
File path: superset/models/reports.py
##########
@@ -102,6 +102,7 @@ class ReportSchedule(Model, AuditMixinNullable):
context_markdown = Column(Text)
active = Column(Boolean, default=True, index=True)
crontab = Column(String(1000), nullable=False)
+ report_format = Column(String(50), default=ReportDataFormat.VISUALIZATION)
Review comment:
Have you changed the format to be applied to all types of notifications,
instead of letting the user choose the format to be sent by email and a
possible different one for Slack for example?
##########
File path: superset/reports/schemas.py
##########
@@ -253,3 +255,4 @@ class ReportSchedulePutSchema(Schema):
validate=[Range(min=1, error=_("Value must be greater than 0"))],
)
recipients = fields.List(fields.Nested(ReportRecipientSchema),
required=False)
+ report_format = fields.String(default=ReportDataFormat.VISUALIZATION)
Review comment:
same here
##########
File path: superset/reports/schemas.py
##########
@@ -178,6 +179,7 @@ class ReportSchedulePostSchema(Schema):
)
recipients = fields.List(fields.Nested(ReportRecipientSchema))
+ report_format = fields.String(default=ReportDataFormat.VISUALIZATION)
Review comment:
Let's add a validation here also:
```
validate=validate.OneOf(choices=tuple(key.value for key in
ReportDataFormat)),
```
This will enrich the OpenAPI spec also
--
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]