File tree Expand file tree Collapse file tree 4 files changed +280
-244
lines changed Expand file tree Collapse file tree 4 files changed +280
-244
lines changed Original file line number Diff line number Diff line change @@ -317,14 +317,22 @@ contract Competition {
317
317
* @param _proposalId proposal id
318
318
* @param _suggestionId suggestion id
319
319
*/
320
+ // solhint-disable-next-line code-complexity
320
321
function refreshTopSuggestions (bytes32 _proposalId , uint256 _suggestionId ) private {
321
322
uint256 [] storage topSuggestions = proposals[_proposalId].topSuggestions;
322
- if (topSuggestions.length < proposals[_proposalId].numberOfWinners) {
323
+ uint256 topSuggestionsLength = topSuggestions.length ;
324
+ uint256 i;
325
+ if (topSuggestionsLength < proposals[_proposalId].numberOfWinners) {
326
+ for (i = 0 ; i < topSuggestionsLength; i++ ) {
327
+ if (topSuggestions[i] == _suggestionId) {
328
+ return ;
329
+ }
330
+ }
323
331
topSuggestions.push (_suggestionId);
324
332
} else {
325
333
/** get the index of the smallest element **/
326
334
uint256 smallest = 0 ;
327
- for (uint256 i ; i < proposals[_proposalId].numberOfWinners; i++ ) {
335
+ for (i = 0 ; i < proposals[_proposalId].numberOfWinners; i++ ) {
328
336
if (suggestions[topSuggestions[i]].totalVotes <
329
337
suggestions[topSuggestions[smallest]].totalVotes) {
330
338
smallest = i;
You can’t perform that action at this time.
0 commit comments