Skip to content

Commit

Permalink
chore: getter for milestone formated
Browse files Browse the repository at this point in the history
  • Loading branch information
naneey committed Oct 9, 2023
1 parent 323bede commit 31d0031
Showing 1 changed file with 60 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1232,8 +1232,6 @@ private void updateProgressReportResult() {

boolean _budget_adjustment = (boolean) _report_result.get(BUDGET_ADJUSTMENT);

// checking which prep(s) did not vote the progress report
checkInactivePreps(ProgressReportDataDb.votersList.at(progressPrefix));// TODO: fix this, voterList to be where

// If a progress report have any budget_adjustment, then it checks the budget adjustment first
if (_budget_adjustment && getBudgetAdjustmentFeature()) {
Expand Down Expand Up @@ -1538,9 +1536,10 @@ private void updateProgressReportStatus(String progressHash, String progressStat
private void updateMilestoneStatus(String milestonePrefix, int milestoneStatus, String progressHash ){

MilestoneDb.status.at(milestonePrefix).set(milestoneStatus);
MilestoneDb.progressReportHash.at(milestonePrefix).set(progressHash);
// MilestoneDb.progressReportHash.at(milestonePrefix).set(progressHash);

// TODO: better name here
// TODO: better name here -> is this even required
// fetch data from pogrss hash? // NOT SO REQUIRED
ArrayDB<String> progressTOm = this.progressReportToMilestone.at(progressHash);
if(!ArrayDBUtils.containsInArrayDb(milestonePrefix,progressTOm)) {
this.progressReportToMilestone.at(progressHash).add(milestonePrefix);
Expand Down Expand Up @@ -1668,9 +1667,18 @@ public Map<String, Object> getBudgetAdjustmentDetails(String progressKey) {
String progressReportKey = progressReportKeys.get(i);
Map<String, Object> progressReportDetails = this.getProgressReportDetails(progressReportKey);
String progressStatus = (String) progressReportDetails.get(STATUS);
String ipfsHash = (String) progressReportDetails.get(IPFS_HASH);
int milestoneCount = getMilestoneCount(ipfsHash);

if (progressStatus.equals(status)) {

if (progressStatus.equals(status) && milestoneCount == 0) {
progressReportList.add(progressReportDetails);
progressReportList.add(getProgressReportVoteDetails(progressReportKey));
} else if (progressStatus.equals(status) && milestoneCount > 0) {

Map<String, Object> progressReportWithMilestone = getMilestoneReport(progressReportKey,ipfsHash);
progressReportList.add(progressReportDetails);
progressReportList.add(progressReportWithMilestone);
}
}
return Map.of(DATA, progressReportList, COUNT, count);
Expand All @@ -1684,12 +1692,57 @@ public Map<String, Object> getBudgetAdjustmentDetails(String progressKey) {
:rtype : dict
***/
@Override
@External(readonly = true)
@External(readonly = true)// include the votes and total voters here?
public Map<String, Object> getProgressReportsByHash(String reportKey) {
if (progressKeyExists(reportKey)) {
return getProgressReportDetails(reportKey);
return getProgressReportByHash_Proxy(reportKey);
}
return Map.of();
}

private Map<String,Object> getMilestoneReport(String reportKey, String ipfsHash){
Map<String,Object> milestoneReport = new HashMap<>();
ArrayDB<Integer> mileSubmitted = milestoneSubmitted.at(progressReportPrefix(reportKey));
for (int i = 0; i < mileSubmitted.size(); i++) {
int count = mileSubmitted.get(i);
milestoneReport.put("milestone_"+count,getMilestonesReport(ipfsHash,count));
}
return milestoneReport;
}

@External(readonly = true)
public Map<String, Object> getProgressReportByHash_Proxy(String reportKey){
if (progressKeyExists(reportKey)) {
Map<String,Object> finalDetail = new HashMap<>();
Map<String,Object> progressReportDetails = getProgressReportDetails(reportKey);
finalDetail.putAll(progressReportDetails);
String ipfsHash = (String) progressReportDetails.get(IPFS_HASH);
int milestoneCount = getMilestoneCount(ipfsHash);

if (milestoneCount > 0){
Map<String,Object> milestoneReport = getMilestoneReport(reportKey,ipfsHash);

finalDetail.put("milestoneReport",milestoneReport);
}
else {
finalDetail.putAll(getVoteResultsFromProgressReportDB(reportKey));
}

return finalDetail;
}
return Map.of();
}

//
//
// @External(readonly = true)
// public Map<String, Object> getDummyData(String reportKey){
//
// String prefix = progressReportPrefix(reportKey);
// Context.println("here");
// return getDataFromProgressReportDB(prefix);
//
// }


}
Expand Down

0 comments on commit 31d0031

Please sign in to comment.