this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Special rounding precision for poll percentage

+13 -2
+13 -2
src/components/status.jsx
··· 923 923 924 924 const expiresAtDate = !!expiresAt && new Date(expiresAt); 925 925 926 + const pollVotesCount = votersCount || votesCount; 927 + let roundPrecision = 0; 928 + if (pollVotesCount <= 1000) { 929 + roundPrecision = 0; 930 + } else if (pollVotesCount <= 10000) { 931 + roundPrecision = 1; 932 + } else if (pollVotesCount <= 100000) { 933 + roundPrecision = 2; 934 + } 935 + 926 936 return ( 927 937 <div 928 938 class={`poll ${readOnly ? 'read-only' : ''} ${ ··· 932 942 {voted || expired ? ( 933 943 options.map((option, i) => { 934 944 const { title, votesCount: optionVotesCount } = option; 935 - const pollVotesCount = votersCount || votesCount; 936 945 const percentage = 937 - Math.round((optionVotesCount / pollVotesCount) * 100) || 0; 946 + ((optionVotesCount / pollVotesCount) * 100).toFixed( 947 + roundPrecision, 948 + ) || 0; 938 949 // check if current poll choice is the leading one 939 950 const isLeading = 940 951 optionVotesCount > 0 &&