@@ -668,110 +668,6 @@ std::vector<polling::Poll> GetPolls(bool bDetail, bool includeExpired, std::stri
668
668
return vPolls;
669
669
}
670
670
671
- UniValue GetJSONPollsReport (bool bDetail, std::string QueryByTitle, std::string& out_export, bool IncludeExpired)
672
- {
673
- // Title,ExpirationDate, Question, Answers, ShareType(1=Magnitude,2=Balance,3=Both)
674
- UniValue results (UniValue::VARR);
675
- UniValue entry (UniValue::VOBJ);
676
- entry.pushKV (" Polls" ," Polls Report " + QueryByTitle);
677
- std::string rows;
678
- std::string row;
679
- double iPollNumber = 0 ;
680
- double total_participants = 0 ;
681
- double total_shares = 0 ;
682
- boost::to_lower (QueryByTitle);
683
- std::string sExport ;
684
- std::string sExportRow ;
685
- out_export.clear ();
686
-
687
- for (const auto & item : ReadCacheSection (Section::POLL))
688
- {
689
- const std::string& title = boost::to_lower_copy (item.first );
690
- const std::string& contract = item.second .value ;
691
- std::string Expiration = ExtractXML (contract," <EXPIRATION>" ," </EXPIRATION>" );
692
- std::string Question = ExtractXML (contract," <QUESTION>" ," </QUESTION>" );
693
- std::string Answers = ExtractXML (contract," <ANSWERS>" ," </ANSWERS>" );
694
- std::string ShareType = ExtractXML (contract," <SHARETYPE>" ," </SHARETYPE>" );
695
- std::string sURL = ExtractXML (contract," <URL>" ," </URL>" );
696
- if (!PollExpired (title) || IncludeExpired)
697
- {
698
- if (QueryByTitle.empty () || QueryByTitle == title)
699
- {
700
-
701
- if ( (title.length ()>128 ) &&
702
- (Expiration.length ()>64 ) &&
703
- (Question.length ()>4096 ) &&
704
- (Answers.length ()>8192 ) &&
705
- (ShareType.length ()>64 ) &&
706
- (sURL .length ()>256 ) )
707
- continue ;
708
-
709
- const std::vector<std::string>& vAnswers = split (Answers.c_str ()," ;" );
710
-
711
- std::string::size_type longestanswer = 0 ;
712
- for (const std::string& answer : vAnswers)
713
- longestanswer = std::max ( longestanswer, answer.length () );
714
-
715
- if ( longestanswer>128 )
716
- continue ;
717
-
718
- iPollNumber++;
719
- total_participants = 0 ;
720
- total_shares=0 ;
721
- std::string BestAnswer;
722
- double highest_share = 0 ;
723
- std::string ExpirationDate = TimestampToHRDate (RoundFromString (Expiration,0 ));
724
- std::string sShareType = GetShareType (RoundFromString (ShareType,0 ));
725
- std::string TitleNarr = " Poll #" + RoundToString ((double )iPollNumber,0 )
726
- + " (" + ExpirationDate + " ) - " + sShareType ;
727
-
728
- entry.pushKV (TitleNarr,title);
729
- sExportRow = " <POLL><URL>" + sURL + " </URL><TITLE>" + title + " </TITLE><EXPIRATION>" + ExpirationDate + " </EXPIRATION><SHARETYPE>" + sShareType + " </SHARETYPE><QUESTION>" + Question + " </QUESTION><ANSWERS>" +Answers+" </ANSWERS>" ;
730
-
731
- if (bDetail)
732
- {
733
- entry.pushKV (" Question" ,Question);
734
- sExportRow += " <ARRAYANSWERS>" ;
735
- size_t i = 0 ;
736
- for (const std::string& answer : vAnswers)
737
- {
738
- double participants=0 ;
739
- double dShares = VotesCount (title, answer, RoundFromString (ShareType,0 ),participants);
740
- if (dShares > highest_share)
741
- {
742
- highest_share = dShares;
743
- BestAnswer = answer;
744
- }
745
-
746
- entry.pushKV (" #" + ToString (++i) + " [" + RoundToString (participants,3 ) + " ]. " + answer,dShares);
747
- total_participants += participants;
748
- total_shares += dShares;
749
- sExportRow += " <RESERVED></RESERVED><ANSWERNAME>" + answer + " </ANSWERNAME><PARTICIPANTS>" + RoundToString (participants,0 ) + " </PARTICIPANTS><SHARES>" + RoundToString (dShares,0 ) + " </SHARES>" ;
750
- }
751
- sExportRow += " </ARRAYANSWERS>" ;
752
-
753
- // Totals:
754
- entry.pushKV (" Participants" ,total_participants);
755
- entry.pushKV (" Total Shares" ,total_shares);
756
- if (total_participants < 3 ) BestAnswer = " " ;
757
-
758
- entry.pushKV (" Best Answer" ,BestAnswer);
759
- sExportRow += " <TOTALPARTICIPANTS>" + RoundToString (total_participants,0 )
760
- + " </TOTALPARTICIPANTS><TOTALSHARES>" + RoundToString (total_shares,0 )
761
- + " </TOTALSHARES><BESTANSWER>" + BestAnswer + " </BESTANSWER>" ;
762
-
763
- }
764
- sExportRow += " </POLL>" ;
765
- sExport += sExportRow ;
766
- }
767
- }
768
- }
769
-
770
- results.push_back (entry);
771
- out_export = sExport ;
772
- return results;
773
- }
774
-
775
671
UniValue GetJsonVoteDetailsReport (std::string pollname)
776
672
{
777
673
double total_shares = 0 ;
0 commit comments