Skip to content

Commit

Permalink
Merge branch 'develop' into feature/oct-1633-PoU
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Jul 8, 2024
2 parents e723497 + cbf6dcb commit a4c6359
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 70 deletions.
2 changes: 1 addition & 1 deletion client/src/api/errorMessages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import toastService from 'services/toastService';
import { QueryMutationError, QueryMutationErrorConfig, IgnoredQueries } from './types';

const IGNORED_QUERIES: IgnoredQueries = [
QUERY_KEYS.withdrawals,
ROOTS.cryptoValues,
ROOTS.individualReward,
ROOTS.projectsIpfsResults,
QUERY_KEYS.withdrawals,
];

const errors: QueryMutationErrorConfig = {
Expand Down
2 changes: 1 addition & 1 deletion client/src/api/errorMessages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export type QueryMutationErrorConfig = {
};

export type IgnoredQueries = [
QueryKeys['withdrawals'],
Root['cryptoValues'],
Root['individualReward'],
Root['projectsIpfsResults'],
QueryKeys['withdrawals'],
];
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const MetricsProjectsList: FC<MetricsProjectsListProps> = ({
value={
getValuesToDisplay({
cryptoCurrency: 'ethereum',
getFormattedEthValueProps: {
shouldIgnoreGwei: true,
shouldIgnoreWei: true,
},
valueCrypto: project.value,
}).primary
}
Expand Down
86 changes: 43 additions & 43 deletions client/src/components/ui/PieChart/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,10 @@ const testCases = [
],
outputData: [
{
angle: 1.9332877868244882,
angle: 2.8999316802367323,
angle0: 0,
color: '#177967',
id: 0,
label: 'A',
percentageValue: 31,
radius: 72,
radius0: 72,
value: 100,
valueLabel: '100 ETH',
},
{
angle: 4.8332194670612205,
angle0: 1.9332877868244882,
color: '#17B239',
id: 1,
id: 0,
label: 'B',
percentageValue: 46,
radius: 72,
Expand All @@ -50,29 +38,41 @@ const testCases = [
valueLabel: '150 ETH',
},
{
angle: 5.316541413767343,
angle0: 4.8332194670612205,
angle: 4.8332194670612205,
angle0: 2.8999316802367323,
color: '#FF9601',
id: 2,
label: 'C',
percentageValue: 8,
id: 1,
label: 'A',
percentageValue: 31,
radius: 72,
radius0: 72,
value: 25,
valueLabel: '25 ETH',
value: 100,
valueLabel: '100 ETH',
},
{
angle: 6.283185307179586,
angle0: 5.316541413767343,
angle: 5.799863360473465,
angle0: 4.8332194670612205,
color: '#2D9B87',
id: 3,
id: 2,
label: 'D',
percentageValue: 15,
radius: 72,
radius0: 72,
value: 50,
valueLabel: '50 ETH',
},
{
angle: 6.283185307179586,
angle0: 5.799863360473465,
color: '#685B8A',
id: 3,
label: 'C',
percentageValue: 8,
radius: 72,
radius0: 72,
value: 25,
valueLabel: '25 ETH',
},
],
radius: 72,
},
Expand Down Expand Up @@ -101,21 +101,21 @@ const testCases = [
],
outputData: [
{
angle: 0.8975979010256552,
angle: 2.962073073384662,
angle0: 0,
color: '#177967',
color: '#17B239',
id: 0,
label: 'A',
percentageValue: 14,
label: 'D',
percentageValue: 47,
radius: 50,
radius0: 50,
value: 10,
valueLabel: '10 ETH',
value: 33,
valueLabel: '33 ETH',
},
{
angle: 2.2439947525641375,
angle0: 0.8975979010256552,
color: '#17B239',
angle: 4.308469924923145,
angle0: 2.962073073384662,
color: '#FF9601',
id: 1,
label: 'B',
percentageValue: 21,
Expand All @@ -125,9 +125,9 @@ const testCases = [
valueLabel: '15 ETH',
},
{
angle: 3.3211122337949237,
angle0: 2.2439947525641375,
color: '#FF9601',
angle: 5.385587406153931,
angle0: 4.308469924923145,
color: '#2D9B87',
id: 2,
label: 'C',
percentageValue: 17,
Expand All @@ -137,16 +137,16 @@ const testCases = [
valueLabel: '12 ETH',
},
{
angle: 6.283185307179585,
angle0: 3.3211122337949237,
color: '#2D9B87',
angle: 6.283185307179586,
angle0: 5.385587406153931,
color: '#685B8A',
id: 3,
label: 'D',
percentageValue: 47,
label: 'A',
percentageValue: 14,
radius: 50,
radius0: 50,
value: 33,
valueLabel: '33 ETH',
value: 10,
valueLabel: '10 ETH',
},
],
radius: 50,
Expand Down
53 changes: 32 additions & 21 deletions client/src/components/ui/PieChart/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,46 @@ import { PieChartData, PieChartInputData } from './types';
export const getPieChartData = (data: PieChartInputData, radius: number): PieChartData => {
// imported colors from styles module are undefined during test
const pieChartColors = [
'#177967',
'#17B239',
'#FF9601',
'#2D9B87',
'#FF6157',
'#685B8A',
'#1D4558',
'#177967',
'#F6C54B',
'#FF6157',
];

const totalValue = data.reduce((acc, curr) => acc + curr.value, 0);

return data.reduce((acc, curr, idx) => {
const fractionValue = curr.value / totalValue;
const angle0 = acc.length ? acc[acc.length - 1].angle : 0;
return data
.sort((a, b) => {
if (a.value < b.value) {
return 1;
}
if (a.value > b.value) {
return -1;
}
return 0;
})
.reduce((acc, curr, idx) => {
const fractionValue = curr.value / totalValue;
const angle0 = acc.length ? acc[acc.length - 1].angle : 0;

const angle = (angle0 / (2 * Math.PI) + fractionValue) * 2 * Math.PI;
const el = {
angle,
angle0,
color: pieChartColors[idx % pieChartColors.length],
id: idx,
label: curr.label,
percentageValue: Math.round(fractionValue * 100),
radius,
radius0: radius,
value: curr.value,
valueLabel: curr.valueLabel,
};
acc.push(el);
return acc;
}, [] as PieChartData);
const angle = (angle0 / (2 * Math.PI) + fractionValue) * 2 * Math.PI;
const el = {
angle,
angle0,
color: pieChartColors[idx % pieChartColors.length],
id: idx,
label: curr.label,
percentageValue: Math.round(fractionValue * 100),
radius,
radius0: radius,
value: curr.value,
valueLabel: curr.valueLabel,
};
acc.push(el);
return acc;
}, [] as PieChartData);
};
4 changes: 2 additions & 2 deletions client/src/constants/milestones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ export default function getMilestones(): Milestone[] {
label: i18n.t('views.projects.projectsTimelineWidget.projectUpdatesClose'),
},
{
from: new Date('2024-06-10T00:00:00+0200'),
from: new Date('2024-06-17T00:00:00+0200'),
id: 'e4-snapshot-vote',
label: i18n.t('views.projects.projectsTimelineWidget.snapshotVote'),
to: new Date('2024-06-15T00:00:00+0200'),
to: new Date('2024-06-21T00:00:00+0200'),
},
{
from: new Date('2024-07-15T18:00:00+0200'),
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/helpers/useIndividualRewardAllEpochs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default function useIndividualRewardAllEpochs({
queries: [...Array(currentEpoch).keys()].map(epoch => ({
enabled: !!address && currentEpoch !== undefined && currentEpoch > 1 && isEnabledAdditional,
queryFn: () => {
// For Epoch 0 and Epoch 1 error 400 is returned.
if ([0, 1].includes(epoch)) {
// For Epoch 0 error 400 is always returned.
if ([0].includes(epoch)) {
return new Promise<Response>(resolve => {
resolve({ budget: '0' });
});
Expand Down

0 comments on commit a4c6359

Please sign in to comment.