Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IPCT1-486] - replace community state #147

Merged
merged 12 commits into from
Dec 7, 2021
Merged

Conversation

dev-jotape
Copy link
Collaborator

@dev-jotape dev-jotape commented Nov 16, 2021

This PR fixes [IPCT1-486] at https://impactmarket.atlassian.net/browse/IPCT1-486

Changes

removed triggers on tables:

  • beneficiary
  • manager

edited triggers on table:

  • ubi_claim
  • inflow

changed get community state to get the previous state + today's state

New

  • migration created to calculate the totalClaim, totalRaised and totalBeneficiaries (since the beginning)
  • migration created to calculate the totalManagers. As we don't have the sum of the managers day by day, I defined the total of managers only in the last record of the ubi_community_daily_state table

Tests

@dev-jotape dev-jotape marked this pull request as ready for review November 22, 2021 18:45
src/services/ubi/community.ts Outdated Show resolved Hide resolved
src/services/ubi/community.ts Outdated Show resolved Hide resolved
src/services/ubi/community.ts Outdated Show resolved Hide resolved
src/database/migrations/zz-create-triggers.js Outdated Show resolved Hide resolved
src/database/migrations/zz-create-triggers.js Outdated Show resolved Hide resolved
@dev-jotape
Copy link
Collaborator Author

@obernardovieira ready to review

@@ -40,18 +40,18 @@
* description: Number of unique backers since contract inception
*/
export interface UbiCommunityState {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all instances of the community state table

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but do not add a drop table yet (needs to be at a later stage)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!
I kept only the interface

Comment on lines 30 to 33
-- SELECT SUM(raised + NEW.amount) INTO state_raised FROM ubi_community_state WHERE "communityId"=community_id;
-- UPDATE ubi_community_state SET raised = state_raised WHERE "communityId"=community_id;
-- SELECT SUM(raised + NEW.amount) INTO state_daily_raised FROM ubi_community_daily_state WHERE "communityId"=community_id AND date=DATE(NEW."txAt");
-- UPDATE ubi_community_daily_state SET raised = state_daily_raised WHERE "communityId"=community_id AND date=DATE(NEW."txAt");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused lines on this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vibern0
Copy link
Contributor

vibern0 commented Dec 3, 2021

Feels like we are getting to the other side of the tunnel 👀

@sonarcloud
Copy link

sonarcloud bot commented Dec 3, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@vibern0 vibern0 merged commit 89215ec into master Dec 7, 2021
@vibern0 vibern0 deleted the refactor/community-state branch December 7, 2021 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants