BI Reports - Refresh Screen
Introduction
The report_refresh_status function reports the refresh status of a Power BI dataset for a specified company. The report_generate_embedToken function is responsible for generating an embed token and URL for a Power BI report.
Pre-Conditions
- Valid JWT token is present in the request for authentication.
- Request contains valid JSON data with the
dataSetId. - The database contains relevant
bi_reportsdata for the specifiedcompanyIdanddataSetId. - Power BI access token can be retrieved successfully.
Course of Events
- Extract JSON data from the request.
- Extract JWT data and extract
companyId. - Extract dataSetId from the request data.
- Obtain Power BI access token using get_powerbi_access_token().
- Query the database for dataset information using companyId and dataSetId.
- If the dataset is found, retrieve
last_refresh_id,last_refresh_user,last_refresh_date, andlast_refresh_status. - Check if the access token is valid.
- Send a GET request to the Power BI API to fetch refresh status.
- Extract refresh status from API response.
- Compare the current status with the last recorded status and update the database if it has changed to "Completed"
- Return a JSON response with status information.
- Then, call
report_generate_embedTokenand follow initial verification. - Construct Power BI API URLs for generating the embed token and retrieving the embed URL.
- Send a POST request to the Power BI API to generate the embed token.
- Send a GET request to the Power BI API to retrieve the embed URL and process the API responses to extract the embed token and embed URL.
- Return a JSON response with the embed token, embed URL, and an HTTP status code.
Validation Checks
- Validate presence of
companyIdanddataSetIdin the request. - Validate the JWT token and extract
companyId. - Validate the presence of bi_reports data for the given
companyIdanddataSetId. - Validate the Power BI access token.
- Validate the Power BI API response status code.
Post Conditions
Return JSON response with:
- status of the dataset refresh.
- last_refresh_date of the dataset.
- last_refresh_user who initiated the last refresh.
- embedToken for embedding the Power BI report.
- embedUrl for accessing the embedded report.
- HTTP status code.
Database is updated if the refresh status has changed to "Completed".
Ensure secure and appropriate access level for the generated embed token.
Exceptions
- None