-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reports are own entities (#2106)
closes #2104 MIGRATION REQUIRED Co-authored-by: Sebastian <sebastian@aam-digital.com>
- Loading branch information
1 parent
9d906f2
commit d742e69
Showing
10 changed files
with
207 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
src/app/features/reporting/demo-report-config-generator.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { DemoDataGenerator } from "../../core/demo-data/demo-data-generator"; | ||
import { ReportConfig } from "./report-config"; | ||
import { Child } from "../../child-dev-project/children/model/child"; | ||
import { School } from "../../child-dev-project/schools/model/school"; | ||
import { ChildSchoolRelation } from "../../child-dev-project/children/model/childSchoolRelation"; | ||
import { EventNote } from "../../child-dev-project/attendance/model/event-note"; | ||
import { EducationalMaterial } from "../../child-dev-project/children/educational-material/model/educational-material"; | ||
|
||
@Injectable() | ||
export class DemoReportConfigGeneratorService extends DemoDataGenerator<ReportConfig> { | ||
static provider() { | ||
return [ | ||
{ | ||
provide: DemoReportConfigGeneratorService, | ||
useClass: DemoReportConfigGeneratorService, | ||
}, | ||
]; | ||
} | ||
|
||
protected generateEntities(): ReportConfig[] { | ||
return demoReports.map((report) => ReportConfig.create(report)); | ||
} | ||
} | ||
|
||
const demoReports: Partial<ReportConfig>[] = [ | ||
{ | ||
title: $localize`:Name of a report:Basic Report`, | ||
aggregationDefinitions: [ | ||
{ | ||
query: `${Child.ENTITY_TYPE}:toArray[*isActive=true]`, | ||
label: $localize`:Label of report query:All children`, | ||
groupBy: ["gender"], | ||
}, | ||
{ | ||
query: `${School.ENTITY_TYPE}:toArray`, | ||
label: $localize`:Label for report query:All schools`, | ||
aggregations: [ | ||
{ | ||
label: $localize`:Label for report query:Children attending a school`, | ||
query: `:getRelated(${ChildSchoolRelation.ENTITY_TYPE}, schoolId)[*isActive=true].childId:unique`, | ||
}, | ||
{ | ||
label: $localize`:Label for report query:Governmental schools`, | ||
query: `[*privateSchool!=true]`, | ||
}, | ||
{ | ||
query: `[*privateSchool!=true]:getRelated(${ChildSchoolRelation.ENTITY_TYPE}, schoolId)[*isActive=true].childId:addPrefix(${Child.ENTITY_TYPE}):unique:toEntities`, | ||
label: $localize`:Label for report query:Children attending a governmental school`, | ||
groupBy: ["gender"], | ||
}, | ||
{ | ||
label: $localize`:Label for report query:Private schools`, | ||
query: `[*privateSchool=true]`, | ||
}, | ||
{ | ||
query: `[*privateSchool=true]:getRelated(${ChildSchoolRelation.ENTITY_TYPE}, schoolId)[*isActive=true].childId:addPrefix(${Child.ENTITY_TYPE}):unique:toEntities`, | ||
label: $localize`:Label for report query:Children attending a private school`, | ||
groupBy: ["gender"], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
title: $localize`:Name of a report:Event Report`, | ||
aggregationDefinitions: [ | ||
{ | ||
query: `${EventNote.ENTITY_TYPE}:toArray[*date >= ? & date <= ?]`, | ||
groupBy: ["category"], | ||
label: $localize`:Label for a report query:Events`, | ||
aggregations: [ | ||
{ | ||
query: `:getParticipantsWithAttendance(PRESENT):unique:addPrefix(${Child.ENTITY_TYPE}):toEntities`, | ||
groupBy: ["gender"], | ||
label: $localize`:Label for a report query:Participants`, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
title: $localize`:Name of a report:Attendance Report`, | ||
mode: "exporting", | ||
aggregationDefinitions: [ | ||
{ | ||
query: `${EventNote.ENTITY_TYPE}:toArray[* date >= ? & date <= ?]`, | ||
groupBy: { label: "Type", property: "category" }, | ||
subQueries: [ | ||
{ | ||
query: ":getAttendanceArray:getAttendanceReport", | ||
subQueries: [ | ||
{ | ||
label: $localize`:Name of a column of a report:Name`, | ||
query: `.participant:toEntities(Child).name`, | ||
}, | ||
{ | ||
query: | ||
".participant:toEntities(Child):getRelated(ChildSchoolRelation, childId)[*isActive=true]", | ||
subQueries: [ | ||
{ | ||
label: "Class", | ||
query: ".schoolClass", | ||
}, | ||
{ | ||
label: "School", | ||
query: ".schoolId:toEntities(School).name", | ||
}, | ||
], | ||
}, | ||
{ | ||
label: $localize`:Name of a column of a report:Total`, | ||
query: `total`, | ||
}, | ||
{ | ||
label: $localize`:Name of a column of a report:Present`, | ||
query: `present`, | ||
}, | ||
{ | ||
label: $localize`:Name of a column of a report:Rate`, | ||
query: `percentage`, | ||
}, | ||
{ | ||
label: $localize`:Name of a column of a report:Late`, | ||
query: `detailedStatus.LATE`, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
title: $localize`:Name of a report:Materials Distributed`, | ||
mode: "exporting", | ||
aggregationDefinitions: [ | ||
{ | ||
query: `${EducationalMaterial.ENTITY_TYPE}:toArray[*date >= ? & date <= ?]`, | ||
groupBy: { label: "Type", property: "materialType" }, | ||
subQueries: [ | ||
{ | ||
label: "Number of events of handing out", | ||
query: `.materialAmount:count`, | ||
}, | ||
{ | ||
label: "Total Items", | ||
query: `.materialAmount:sum`, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Entity } from "../../core/entity/model/entity"; | ||
import { DatabaseEntity } from "../../core/entity/database-entity.decorator"; | ||
import { Aggregation } from "./data-aggregation.service"; | ||
import { ExportColumnConfig } from "../../core/export/data-transformation-service/export-column-config"; | ||
import { DatabaseField } from "../../core/entity/database-field.decorator"; | ||
|
||
/** | ||
* A report can be accessed by users to generate aggregated statistics or customized exports calculated from available data. | ||
* "read" permission for a ReportConfig entity is also used to control which users can generate the report's results. | ||
*/ | ||
@DatabaseEntity("ReportConfig") | ||
export class ReportConfig extends Entity { | ||
static create(data: Partial<ReportConfig>) { | ||
return Object.assign(new ReportConfig(), data); | ||
} | ||
|
||
/** human-readable title of the report */ | ||
@DatabaseField() title: string; | ||
|
||
/** | ||
* (optional) mode whether the aggregation definitions are of type {@interface Aggregation} or {@interface ExportColumnConfig} | ||
* Default is "reporting" | ||
*/ | ||
@DatabaseField() mode?: "reporting" | "exporting"; | ||
|
||
/** the definitions to calculate the report's aggregations */ | ||
@DatabaseField() aggregationDefinitions?: | ||
| Aggregation[] | ||
| ExportColumnConfig[] = []; | ||
} |
28 changes: 0 additions & 28 deletions
28
src/app/features/reporting/reporting/reporting-component-config.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.