Skip to content

Commit

Permalink
fixed RR:subcounty filter bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
benzerbett committed May 25, 2021
1 parent 0a26b80 commit c501d24
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 60 deletions.
2 changes: 1 addition & 1 deletion public/manifest.webapp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.1.1-beta",
"version": "1.1.2-beta",
"name": "Health Commodities Dashboard - Beta",
"appType": "APP",
"description": "An App to Visualize Health Commodities data",
Expand Down
2 changes: 1 addition & 1 deletion src/views/Accountability/Accountability.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const Accountability = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/DataQuality/DQComparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const DQComparison = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/DataQuality/DQCompleteness.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const DQCompleteness = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
14 changes: 9 additions & 5 deletions src/views/DataQuality/DQConcordance.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ const DQConcordance = props => {
// .then(ad => ad.json())
.then(reply => {
if (reply.fetchedData == undefined || reply.fetchedData?.error) {
setErr({
error: true,
msg: reply?.fetchedData?.message || '',
...reply
});
let e_rr = {
error: true,
msg: reply?.fetchedData?.message || '',
...reply
}
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
console.error(reply)
} else {

///////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/views/DataQuality/DQConsistency.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const DQConsistency = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/HFFollowup/Overstocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const sumArr = arr => arr.reduce((a, b) => a + b, 0);
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/HFFollowup/Understocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const sumArr = arr => arr.reduce((a, b) => a + b, 0);
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/IssuesReceipts/IssuesReceipts.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const IssuesReceipts = props => {
}
console.error(e_rr)
console.error(reply)
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
return e_rr
Expand Down
2 changes: 1 addition & 1 deletion src/views/National/NatCommodities.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const NatCommodities = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/National/NatSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const Dashboard = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/ReportingRate/RRFacility.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const RRFacility = props => {
msg: reply?.fetchedData?.message || '',
...reply
}
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
return e_rr
Expand Down
77 changes: 38 additions & 39 deletions src/views/ReportingRate/RRSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ const RRSummary = props => {
ep => ep.id == 'county__reporting_rate_trend'
)[process.env.REACT_APP_ENV == "dev" ? "local_url" : "url"];
let lv_l = '2'
if(oun == null || oun == '~' || oun == "HfVjCurKxh2" || filter_params?.ou == '~' || filter_params?.ou == 'HfVjCurKxh2'){
if (oun == null || oun == '~' || oun == "HfVjCurKxh2" || filter_params?.ou == '~' || filter_params?.ou == 'HfVjCurKxh2') {
lv_l = '1'
}
let [url, setUrl] = useState(
filterUrlConstructor(
'LAST_6_MONTHS',
filter_params.ou,
lv_l,
"~",//lv_l,
base_rr_url
)
);
Expand All @@ -68,7 +68,7 @@ const RRSummary = props => {
const [latestScRR, setLatestScRR] = useState([[]]);
const [ScRRpe, setScRRpe] = useState('');
const [scrrSubcounties, setScRRsubcs] = useState([[]]);

const [err, setErr] = useState({ error: false, msg: '' });
let title = `Reporting Rate: Summary`;

Expand Down Expand Up @@ -104,11 +104,10 @@ const RRSummary = props => {
msg: reply?.fetchedData?.message || '',
...reply
}
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
console.error("iko shida")
console.error(reply)
console.error(rr_url + " : ", reply)
return e_rr
setErr(e_rr)
} else {
Expand All @@ -132,8 +131,8 @@ const RRSummary = props => {

////////////// rr ////////////////
rr_rows.map(ydate => {
let date8 = ydate[reply.fetchedData.headers.findIndex(jk=>jk.name=="pe")];
let data8 = ydate[reply.fetchedData.headers.findIndex(jk=>jk.name=="value")];
let date8 = ydate[reply.fetchedData.headers.findIndex(jk => jk.name == "pe")];
let data8 = ydate[reply.fetchedData.headers.findIndex(jk => jk.name == "value")];
theorigdate.push(date8);
let ydata = parseFloat(data8).toFixed(2);
matched_data.push(ydata);
Expand All @@ -147,9 +146,9 @@ const RRSummary = props => {
reply.fetchedData.metaData.dimensions.pe.map(o_rr_pe => {
rr_rows.map((rw) => {
let array1 = rw;
if (array1[reply.fetchedData.headers.findIndex(jk=>jk.name=="pe")] === o_rr_pe) {
let findata = parseFloat(array1[reply.fetchedData.headers.findIndex(jk=>jk.name=="value")]);
let lenudate = array1[reply.fetchedData.headers.findIndex(jk=>jk.name=="pe")];
if (array1[reply.fetchedData.headers.findIndex(jk => jk.name == "pe")] === o_rr_pe) {
let findata = parseFloat(array1[reply.fetchedData.headers.findIndex(jk => jk.name == "value")]);
let lenudate = array1[reply.fetchedData.headers.findIndex(jk => jk.name == "pe")];
finalRRdata.push(findata);
xc = 0;
} else xc = 1;
Expand All @@ -170,9 +169,9 @@ const RRSummary = props => {
let matched_data2 = [];
let ondatarr = [];
ot_rr_rows.map(function (ydate2) {
let date82 = ydate2[reply.fetchedData.headers.findIndex(jk=>jk.name=="pe")];
let data82 = ydate2[reply.fetchedData.headers.findIndex(jk=>jk.name=="value")];
let ondt = parseFloat(ydate2[reply.fetchedData.headers.findIndex(jk=>jk.name=="value")]);
let date82 = ydate2[reply.fetchedData.headers.findIndex(jk => jk.name == "pe")];
let data82 = ydate2[reply.fetchedData.headers.findIndex(jk => jk.name == "value")];
let ondt = parseFloat(ydate2[reply.fetchedData.headers.findIndex(jk => jk.name == "value")]);
ondatarr.push(ondt);
theorigdate2.push(date82);
let ydata2 = parseFloat(data82).toFixed(2);
Expand All @@ -188,8 +187,8 @@ const RRSummary = props => {
reply.fetchedData.metaData.dimensions.pe.map(o_on_pe => {
ot_rr_rows.map(rw => {
let array12 = rw;
if (array12[reply.fetchedData.headers.findIndex(jk=>jk.name=="pe")] === o_on_pe) {
let findata2 = parseFloat(array12[reply.fetchedData.headers.findIndex(jk=>jk.name=="value")]);
if (array12[reply.fetchedData.headers.findIndex(jk => jk.name == "pe")] === o_on_pe) {
let findata2 = parseFloat(array12[reply.fetchedData.headers.findIndex(jk => jk.name == "value")]);
finalondata2.push(findata2);
xc1 = 0;
} else xc1 = 1;
Expand Down Expand Up @@ -254,10 +253,10 @@ const RRSummary = props => {
msg: reply?.fetchedData?.message || '',
...reply
}
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
console.error(reply)
console.error(scrr_url + " : ", reply)
return e_rr
setErr(e_rr);
} else {
Expand Down Expand Up @@ -309,7 +308,7 @@ const RRSummary = props => {
useEffect(() => {
let mounted = true
let u_r_l = endpoints[0][process.env.REACT_APP_ENV == "dev" ? "local_url" : "url"]
let ftch = (r_l, scr_l) => {
let ftch = (r_l, scr_l, nfp) => {
fetchRR(r_l).then(dta => {
// console.log('dta: ', dta)
setLoading(false)
Expand All @@ -319,23 +318,24 @@ const RRSummary = props => {
updateRRData(dta?.rr?.data, dta?.rr?.periods, dta?.rr?.orgs, null);
updateOTRRData(dta?.ot?.data, dta?.ot?.periods, dta?.ot?.orgs, null);
}
}).then(r9t => {
if (nfp?.ou != '~' && nfp?.ou != 'HfVjCurKxh2' && nfp?.ou != null) {
// console.log('SHOW_LATEST')
fetchScRR(scr_l).then((dt_a) => {
let { data, period, orgs } = dt_a
setLoading(false)
if (data?.error && data?.msg) {
setErr(data)
} else {
updateLatestSCRR(data, period, orgs, '')
}
});
} else {
// console.log('HIDE_LATEST:: nfp.ou :: ' + nfp?.ou)
}
});
if(oun == null || oun == '~' || oun == "HfVjCurKxh2" || filter_params?.ou == '~' || filter_params?.ou == 'HfVjCurKxh2'){
console.info('SHW SUMM')
}else{
console.info('NOT NATIONAL')
fetchScRR(scr_l).then((dt_a) => {
let {data, period, orgs} = dt_a
setLoading(false)
if (data?.error && data?.msg) {
setErr(data)
} else {
updateLatestSCRR(data, period, orgs, '')
}
});
}
}
ftch(url, scurl)
ftch(url, scurl, filter_params)
if (mounted) {

props.history.listen((location, action) => {
Expand Down Expand Up @@ -367,13 +367,13 @@ const RRSummary = props => {
setOulvl(new_filter_params.level);
}
let l_vl = '2'
if(oun == null || oun == '~' || oun == "HfVjCurKxh2"){
if (oun == null || oun == '~' || oun == "HfVjCurKxh2") {
l_vl = '1'
}
let new_url = filterUrlConstructor(
new_filter_params.pe,
new_filter_params.ou,
l_vl,
"~", //l_vl,
base_rr_url
);
let new_scurl = filterUrlConstructor(
Expand All @@ -382,8 +382,7 @@ const RRSummary = props => {
'3',
base_scrr_url
);
ftch(new_url);
ftch(new_scurl);
ftch(new_url, new_scurl, new_filter_params);
}
});
}
Expand All @@ -398,7 +397,7 @@ const RRSummary = props => {
// console.log('period_s: ', JSON.stringify(period_s))
// console.log('otrrdata: ', JSON.stringify(otrrdata))
// console.log('rrdata: ', JSON.stringify(rrdata))

let trnd = {}
trnd.pe = period_s
trnd.ot = otrrdata
Expand Down
2 changes: 1 addition & 1 deletion src/views/StockStatus/StockStatusAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const StockStatusAll = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/StockStatus/StockStatusMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const StockStatusMap = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/StockStatus/StockStatusOne.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const StockStatusOne = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/SupplyChain/SCSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const SCSummary = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/views/SupplyChain/SCTrends.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const SCTrends = props => {
...reply
}
setErr(e_rr);
if (e_rr.msg.includes('aborted')) {
if (e_rr.msg.includes('aborted') || e_rr.msg.includes('NetworkError')) {
props.history.go(0)
}
} else {
Expand Down

0 comments on commit c501d24

Please sign in to comment.