Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Brajesh Kumar authored and Brajesh Kumar committed Oct 12, 2023
1 parent 3a38701 commit 3a6abe4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ng-container>
<ng-container *ngIf="title.Average">
<span i18n="Average amount|Average amount of education material including a summary">
<strong>Average:</strong> {{ avgSummary }}
<strong>Average:</strong> {{ avgSummary }}
</span>
</ng-container>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { EntityMapperService } from "../../../../core/entity/entity-mapper/entit
import { of, Subject } from "rxjs";
import { UpdatedEntity } from "../../../../core/entity/model/entity-update";
import { ActivatedRoute } from "@angular/router";
import { RouteData } from "app/core/config/dynamic-routing/view-config.interface";

describe("EducationalMaterialComponent", () => {
let component: EducationalMaterialComponent;
Expand Down Expand Up @@ -123,6 +122,7 @@ describe("EducationalMaterialComponent", () => {
const newRecord = component.newRecordFactory();
expect(newRecord.child).toBe(child.getId());
});

it("produces an empty summary when there are no records", () => {
component.records = [];
component.updateSummary();
Expand All @@ -131,25 +131,6 @@ describe("EducationalMaterialComponent", () => {

it("should set summaryTitle based on panel title", () => {
setRecordsAndGenerateSummary([{ Total: "Total" }, { Average: "Average" }])

const routeData: RouteData = {
config: {
panels: [
{
title: "Educational Materials",
summary: [
{
Total: "Total",
},
{
Average: "Average",
},
],
},
],
},
};

component.getSummaryList();
expect(component.summaryTitle).toEqual([{ Total: "Total" }, { Average: "Average" }]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export class EducationalMaterialComponent implements OnInit {
const summary = new Map<string, { count: number; sum: number }>();
const average = new Map<string, number>();

// Initialize summary and average maps in a single loop
for (const m of this.records) {
if (m.materialType) {
const label = m.materialType.label;
Expand All @@ -117,11 +116,10 @@ export class EducationalMaterialComponent implements OnInit {

const summaryArray: string[] = [];
const avgSummaryArray: string[] = [];

for (const [label, labelData] of summary.entries()) {
const avg = parseFloat((labelData.sum / labelData.count).toPrecision(2));
average.set(label, avg);

summaryArray.push(`${label}: ${labelData.sum}`);
avgSummaryArray.push(`${label}: ${avg}`);
}
Expand All @@ -131,13 +129,12 @@ export class EducationalMaterialComponent implements OnInit {
this.getSummaryList();
}


getSummaryList(){
getSummaryList() {
this.route.data.subscribe(
(data: RouteData<EntityListConfig>) => (this.listConfig = data.config),
);
this.summaryTitle = this.listConfig['panels']
.find((panel: { title: string })=> panel.title === "Educational Materials").summary;


this.summaryTitle = this.listConfig['panels']
.find((panel: { title: string })=> panel.title === "Educational Materials").summary;
}
}

0 comments on commit 3a6abe4

Please sign in to comment.