Sparsh1212 / gsocanalyzer

A blazingly fast tool to analyze all the selected organizations in Google Summer of Code in the form of graphical analytics.
MIT License
75 stars 39 forks source link

Changing filters leads to incorrect organization data #50

Closed Sparsh1212 closed 2 years ago

Sparsh1212 commented 2 years ago

When we change filters then somehow the organization card data is getting changed and some incorrect data is being rendered. This is a major bug that needs to be fixed ASAP.

Observe Oppia Foundation stats getting changed upon changing filters.

https://user-images.githubusercontent.com/55937724/144717032-55c08435-4b68-4a91-8d0a-7a320bdf9f4f.mp4

HumanChwan commented 2 years ago

Hey! I believe the issue is with the project Array being passed as reference in the Line Component of react-chartjs-2 (file: src/components/OrganisationCard.js), which modifies the organisation object itself. Making a copy (by spreading, or using slice function) of the Array should ensure otherwise.

const graphData = {
    labels: [2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021],
    datasets: [
      {
        label: 'No. of Projects',
        data: [...orgData.project],
        borderColor: '#99A3A4',
        backgroundColor: '#F2F4F4',
        pointBorderColor: '#17202A',
        pointBackgroundColor: '#17202A',
      },
    ],
  };
Sparsh1212 commented 2 years ago

Hey! I believe the issue is with the project Array being passed as reference in the Line Component of react-chartjs-2 (file: src/components/OrganisationCard.js), which modifies the organisation object itself. Making a copy (by spreading, or using slice function) of the Array should ensure otherwise.

const graphData = {
    labels: [2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021],
    datasets: [
      {
        label: 'No. of Projects',
        data: [...orgData.project],
        borderColor: '#99A3A4',
        backgroundColor: '#F2F4F4',
        pointBorderColor: '#17202A',
        pointBackgroundColor: '#17202A',
      },
    ],
  };

I see. This might be the case. Can you please send a PR for this if it works locally.