Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TNO-2072 Charts can now pull content from another report #1458

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

Fosol
Copy link
Collaborator

@Fosol Fosol commented Jan 25, 2024

We can now add Media Analytics sections to a report that reference another report and group the content by sections. This feature requires the report to have an active Report Instance, otherwise the chart will be empty.

Summary

  • Added DB Migration 1.0.115
  • Published tno-core:0.1.21
  • Updated Editor app
  • Updated Subscriber app

Editor Report Admin

image

Editor Chart Template Admin

image

Subscriber Report Admin

image

Subscriber Report Preview

image

@Fosol Fosol added enhancement New feature or request DB Migration A DB Migration may require refreshing or simply updating your database. subscriber PR contains changes towards the subscriber application, tno-core update Indicates that there have been changes to our tno-core package, which can pose concurrency issues. editor labels Jan 25, 2024
@Fosol Fosol self-assigned this Jan 25, 2024
Add DB migration 1.0.115
Publish tno-core:0.1.21
Update Reporting Service
Update Editor app
Update Subscriber app
Update API
content = content.AppendRange(await _reportHelper.FindContentAsync(model.Filter, model.Index));

// If this chart pulls data from a linked report add this content.
var sections = model.LinkedReportId.HasValue ? _reportHelper.GetLinkedReportContent(model.LinkedReportId.Value, null).Result : new();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any section that references a linked report needs to fetch that report's content for the current instance.

/// <param name="reportId"></param>
/// <param name="ownerId"></param>
/// <returns></returns>
public Task<Dictionary<string, ReportSectionModel>> GetLinkedReportContent(int reportId, int? ownerId = null)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic is mostly done here.

[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[SwaggerOperation(Tags = new[] { "Report" })]
public IActionResult GetCurrentInstance(int id, int? requestorId)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to add this endpoint so that the Reporting Service has a way to get the linked report content.

@@ -316,9 +314,35 @@ public async Task<IActionResult> Generate(int id, [FromQuery] bool regenerate =

var instances = _reportService.GetLatestInstances(id, user.Id);
var currentInstance = instances.FirstOrDefault();
if (regenerate && currentInstance != null && currentInstance.SentOn.HasValue == false)
if (currentInstance == null)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a bug where a report would be stuck after it was accepted by CHES but the SentOn date wasn't updated correctly. I don't like this implementation.

@@ -232,7 +232,7 @@ export const ReportEdit: React.FC = () => {
</Button>
) : (
<Button
onClick={() => handleRegenerate(values, false)}
onClick={() => handleRegenerate(values, true)}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to for a new generation


// If the section has content add it to the chart request.
if (!settings.UseAllContent && sectionContent.TryGetValue(section.Name, out ReportSectionModel? sectionData) && sectionData != null)
{
content.AddRange(sectionData.Content);
}
if (section.LinkedReportId.HasValue)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a callback go get the linked report.

@Fosol Fosol marked this pull request as ready for review January 25, 2024 18:00
@Fosol Fosol merged commit bd7fc8d into bcgov:dev Jan 25, 2024
3 checks passed
@Fosol Fosol deleted the tno-2072 branch January 25, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB Migration A DB Migration may require refreshing or simply updating your database. editor enhancement New feature or request subscriber PR contains changes towards the subscriber application, tno-core update Indicates that there have been changes to our tno-core package, which can pose concurrency issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant