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

Feature/yesnopartial report #24

Open
wants to merge 16 commits into
base: development
Choose a base branch
from

Conversation

idelcano
Copy link
Contributor

📌 References

📝 Implementation

got all the rows from a sqlquery with more than 1 response grouped by yes/no/partial categoryoptioncombos.
you can select a group of rows and override the stored value using the dot action menu.
I have tried to change the way to delete the values using deleted:true but doesn't work, maybe the endpoint is different than the endpoint that i use.

Sqlview is in:
https://extranet.who.int/dhis2-dev/api/29/sqlViews/bsywqunulSd
report installed in dev and prod, example:
https://extranet.who.int/dhis2/dhis-web-reports/index.html#/standard-report/view/hSkPEosiPJN

🎨 Screenshots

🔥 Notes to the tester

@idelcano idelcano requested a review from tokland August 23, 2022 15:41
Copy link
Contributor

@tokland tokland left a comment

Choose a reason for hiding this comment

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

[code-only review]
[merge with base branch required]

const NO = "Y7EAGQA1bfv";
const PARTIAL = "Xgr3PJxcWfJ";
const YES = "I93t0K7b1oN";
const DEFAULT = "Xr12mI7VPn3";
Copy link
Contributor

@tokland tokland Oct 24, 2022

Choose a reason for hiding this comment

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

[note] Usually, we try not to hardcode IDs (and get entities by code/name on the config repo). Here it's a very custom app so I guess no need to change it.

categoryOptionCombo: string;
attributeOptionCombo: string;
value?: boolean;
}[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Two identical types, we can create a type alias.

count: item.count,
})
);
if (items === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor] TS says items cannot be undefined. It's that so?

rows.forEach(datavalue => {
if (option === "yes") {
if (datavalue.no === "1") {
this.prepareDataValue(datavalue, NO, "false");
Copy link
Contributor

@tokland tokland Oct 24, 2022

Choose a reason for hiding this comment

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

[functional programming] avoid forEach/push/calling methods that update variables somewhere -> map, compact, methods that return values.

try {
if (this.dataValues.length > 0) {
const responsePush = await this.api
.post<any>("/dataValueSets?importStrategy=CREATE&async=false", {}, { dataValues: this.dataValues })
Copy link
Contributor

Choose a reason for hiding this comment

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

We have the typed endpoint this.api.dataValues.postSet.

value: string;
yes:boolean,
no:boolean,
partial:boolean,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not prettified

@@ -0,0 +1,20 @@
import { Id, NamedRef, Named } from "../common/entities/Base";

export interface DataValue {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this used? we have some custom DataValue for the yesNoPartial

@@ -0,0 +1,41 @@
import { Id } from "../../common/entities/Base";

export interface DataValueItem {
Copy link
Contributor

Choose a reason for hiding this comment

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

[very minor] This Item sufix is a bit redundant.

import { Id } from "../../common/entities/Base";

export interface NHWAYesNoPartialDataValuesRepository {
get(options: NHWAYesNoPartialDataValuesRepositoryGetOptions): Promise<PaginatedObjects<DataValueItem>>;
Copy link
Contributor

@tokland tokland Oct 24, 2022

Choose a reason for hiding this comment

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

[note] On Clean arch, typically we have an entity+repo that work together. Here we have NHWAYesNoPartialDataValues/DataValueItem, which is a bit confusing.


export interface NHWAYesNoPartialDataValuesRepository {
get(options: NHWAYesNoPartialDataValuesRepositoryGetOptions): Promise<PaginatedObjects<DataValueItem>>;
push(dataValues: DataValueItemIdentifier[], option: string): Promise<boolean>;
Copy link
Contributor

Choose a reason for hiding this comment

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

push in the meaning of post?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants