Skip to content

Commit

Permalink
MMI-244 Updated CBRA report (#2314)
Browse files Browse the repository at this point in the history
* MMI-244 Updated CBRA report

- fixed UI styles
- fixed UI date convert issues in core
- fixed the performance issue

* MMI-244 Updated tno-core version
  • Loading branch information
laidaoyu authored Oct 29, 2024
1 parent 318489a commit 4e1fb86
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 66 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion app/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"redux-logger": "3.0.6",
"styled-components": "6.1.11",
"stylis": "4.3.2",
"tno-core": "0.1.150"
"tno-core": "0.1.151"
},
"devDependencies": {
"@simbathesailor/use-what-changed": "2.0.0",
Expand Down
104 changes: 53 additions & 51 deletions app/editor/src/features/reports/cbra/CBRAReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,66 @@ export const CBRAReport: React.FC<ICBRAReportProps> = ({ className }) => {

return (
<styled.CBRAReport className={`${className ?? 'form'}`}>
<Select
name="duration"
label="Report Duration"
options={reportDurations}
defaultValue={reportDurations[0]}
onChange={(value) => {
const option = (value as IOptionItem<number>).value ?? 0;
setValues({
duration: option,
...calcDuration(option),
});
}}
/>
<div className="dates">
<SelectDate
name="start"
label="Report Duration Start"
placeholderText="YYYY MM DD"
onChange={(date) => setValues({ ...values, start: date })}
disabled={!isCustomRange}
selected={values.start}
width={FieldSize.Small}
<div className="report-form">
<Select
name="duration"
label="Report Duration"
options={reportDurations}
defaultValue={reportDurations[0]}
onChange={(value) => {
const option = (value as IOptionItem<number>).value ?? 0;
setValues({
duration: option,
...calcDuration(option),
});
}}
/>
{values.duration > 1 && (
<div className="dates">
<SelectDate
name="end"
label="Report Duration End"
name="start"
label="Report Duration Start"
placeholderText="YYYY MM DD"
onChange={(date) => setValues({ ...values, end: date })}
onChange={(date) => setValues({ ...values, start: date })}
disabled={!isCustomRange}
selected={values.end}
selected={values.start}
width={FieldSize.Small}
/>
)}
</div>
<div className="buttons">
<Button
disabled={!values.start || isDownloading}
loading={isDownloading}
onClick={async () => {
if (values.start) {
try {
setIsDownloading(true);
await api.generateCBRAReport(values.start, values.end);
} finally {
setIsDownloading(false);
{values.duration > 1 && (
<SelectDate
name="end"
label="Report Duration End"
placeholderText="YYYY MM DD"
onChange={(date) => setValues({ ...values, end: date })}
disabled={!isCustomRange}
selected={values.end}
width={FieldSize.Small}
/>
)}
</div>
<div className="buttons">
<Button
disabled={!values.start || isDownloading}
loading={isDownloading}
onClick={async () => {
if (values.start) {
try {
setIsDownloading(true);
await api.generateCBRAReport(values.start, values.end);
} finally {
setIsDownloading(false);
}
}
}
}}
>
Generate CBRA Report
</Button>
<Button
variant={ButtonVariant.secondary}
onClick={() => setValues({ ...values, ...calcDuration(values.duration) })}
>
Clear
</Button>
}}
>
Generate CBRA Report
</Button>
<Button
variant={ButtonVariant.secondary}
onClick={() => setValues({ ...values, ...calcDuration(values.duration) })}
>
Clear
</Button>
</div>
</div>
</styled.CBRAReport>
);
Expand Down
4 changes: 4 additions & 0 deletions app/editor/src/features/reports/cbra/styled/CBRAReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ export const CBRAReport = styled.div`
display: flex;
flex-direction: row;
}
.report-form {
margin-left: 1.5rem;
}
`;
10 changes: 5 additions & 5 deletions app/editor/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11009,7 +11009,7 @@ __metadata:
sass-extract-loader: 1.1.0
styled-components: 6.1.11
stylis: 4.3.2
tno-core: 0.1.150
tno-core: 0.1.151
typescript: 4.9.5
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -15184,9 +15184,9 @@ __metadata:
languageName: node
linkType: hard

"tno-core@npm:0.1.150":
version: 0.1.150
resolution: "tno-core@npm:0.1.150"
"tno-core@npm:0.1.151":
version: 0.1.151
resolution: "tno-core@npm:0.1.151"
dependencies:
"@elastic/elasticsearch": ^8.13.1
"@fortawesome/free-solid-svg-icons": ^6.4.2
Expand Down Expand Up @@ -15219,7 +15219,7 @@ __metadata:
styled-components: ^6.1.11
stylis: ^4.3.2
yup: ^1.1.1
checksum: 89b329c80e1cb8d3539ea244083000f2e96affaaa45ce30bf4f2130f4e9ccd5ef6acad36455715ed3b8b0dc4ea26edbcefc74f54847abcae5424ddf2c206834a
checksum: a30a7aae88e5cfb66c62087c6c4682435553e55dcf8709bad37c51715d9e6650ea1372c64374c61dc0f13b38a43d48ffe164f261eb6330baa3afa9bc2cb6b3b0
languageName: node
linkType: hard

Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion app/subscriber/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"sheetjs": "file:packages/xlsx-0.20.1.tgz",
"styled-components": "6.1.11",
"stylis": "4.3.2",
"tno-core": "0.1.150"
"tno-core": "0.1.151"
},
"devDependencies": {
"@testing-library/jest-dom": "6.4.5",
Expand Down
10 changes: 5 additions & 5 deletions app/subscriber/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10665,7 +10665,7 @@ __metadata:
sheetjs: "file:packages/xlsx-0.20.1.tgz"
styled-components: 6.1.11
stylis: 4.3.2
tno-core: 0.1.150
tno-core: 0.1.151
typescript: 4.9.5
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -14698,9 +14698,9 @@ __metadata:
languageName: node
linkType: hard

"tno-core@npm:0.1.150":
version: 0.1.150
resolution: "tno-core@npm:0.1.150"
"tno-core@npm:0.1.151":
version: 0.1.151
resolution: "tno-core@npm:0.1.151"
dependencies:
"@elastic/elasticsearch": ^8.13.1
"@fortawesome/free-solid-svg-icons": ^6.4.2
Expand Down Expand Up @@ -14733,7 +14733,7 @@ __metadata:
styled-components: ^6.1.11
stylis: ^4.3.2
yup: ^1.1.1
checksum: 89b329c80e1cb8d3539ea244083000f2e96affaaa45ce30bf4f2130f4e9ccd5ef6acad36455715ed3b8b0dc4ea26edbcefc74f54847abcae5424ddf2c206834a
checksum: a30a7aae88e5cfb66c62087c6c4682435553e55dcf8709bad37c51715d9e6650ea1372c64374c61dc0f13b38a43d48ffe164f261eb6330baa3afa9bc2cb6b3b0
languageName: node
linkType: hard

Expand Down
2 changes: 1 addition & 1 deletion libs/net/reports/CBRAReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public XSSFWorkbook GenerateReport(DateTime from, DateTime? to)

// TODO: This is horrible, but hibernate is a mess. Need to make this more
// performant.
content = page.Items.Select(i => contentService.FindById(i.Id)!).ToList();
content = page.Items;

// TODO: Hardcoding isn't good.
talkRadio = content.Where(c => c.MediaType?.Name == "Talk Radio").ToList();
Expand Down
2 changes: 1 addition & 1 deletion libs/npm/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tno-core",
"description": "TNO shared library",
"version": "0.1.150",
"version": "0.1.151",
"homepage": "https://github.com/bcgov/tno",
"license": "Apache-2.0",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion libs/npm/core/src/hooks/api/reports/useApiReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const useApiReports = (
generateCBRAReport: (from: Date, to?: Date | null) => {
const params = {
from: moment(from).format('YYYY-MM-DDT00:00:00'),
to: to ? moment(to).format('YYYY-MM-DDT:11:59:59') : undefined,
to: to ? moment(to).format('YYYY-MM-DDT11:59:59') : undefined,
};
return download({
url: `/reports/cbra?${toQueryString(params)}`,
Expand Down

0 comments on commit 4e1fb86

Please sign in to comment.