Skip to content

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

  1. Valid JWT token is present in the request for authentication.
  2. Request contains valid JSON data with the dataSetId.
  3. The database contains relevant bi_reports data for the specified companyId and dataSetId.
  4. Power BI access token can be retrieved successfully.

Course of Events

  1. Extract JSON data from the request.
  2. Extract JWT data and extract companyId.
  3. Extract dataSetId from the request data.
  4. Obtain Power BI access token using get_powerbi_access_token().
  5. Query the database for dataset information using companyId and dataSetId.
  6. If the dataset is found, retrieve last_refresh_id, last_refresh_user, last_refresh_date, and last_refresh_status.
  7. Check if the access token is valid.
  8. Send a GET request to the Power BI API to fetch refresh status.
  9. Extract refresh status from API response.
  10. Compare the current status with the last recorded status and update the database if it has changed to "Completed"
  11. Return a JSON response with status information.
  12. Then, call report_generate_embedToken and follow initial verification.
  13. Construct Power BI API URLs for generating the embed token and retrieving the embed URL.
  14. Send a POST request to the Power BI API to generate the embed token.
  15. 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.
  16. Return a JSON response with the embed token, embed URL, and an HTTP status code.

Validation Checks

  • Validate presence of companyId and dataSetId in the request.
  • Validate the JWT token and extract companyId.
  • Validate the presence of bi_reports data for the given companyId and dataSetId.
  • Validate the Power BI access token.
  • Validate the Power BI API response status code.

Post Conditions

  1. 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.
  2. Database is updated if the refresh status has changed to "Completed".

  3. Ensure secure and appropriate access level for the generated embed token.

Exceptions

  1. None