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

Add view to retrieve period data #137

Merged
merged 3 commits into from
Jun 12, 2024
Merged

Add view to retrieve period data #137

merged 3 commits into from
Jun 12, 2024

Conversation

fmrsabino
Copy link
Contributor

@fmrsabino fmrsabino commented Jun 11, 2024

What was wrong? 👾

Closes #131

How was it fixed? 🎯

  • Adds an endpoint to retrieve the activity information for a specific Campaign
  • This endpoint can be used to filter the Activities done by a specific holder - by setting the holder address as the query parameter

The endpoint is as follows:

GET /api/v1/campaigns/<uuid:resource_id>/activities/?holder=<address>

{
  "count": <number>,
  "next": <url>, // nullable
  "previous": <url>,  // nullable
  "results": [
    {
      "startDate": <string>, // date string e.g.: 2024-05-20
      "endDate": <string>, // date string e.g.: 2024-05-20
      "holder": <string>, // Holder's address
      "boost": <string>, // decimal string
      "totalPoints": <string>, // big number string
      "totalBoostedPoints": <string> // decimal string
    }
  ]
}

@fmrsabino fmrsabino self-assigned this Jun 11, 2024
@fmrsabino fmrsabino marked this pull request as ready for review June 11, 2024 14:00
@fmrsabino fmrsabino requested a review from a team as a code owner June 11, 2024 14:00
Copy link
Member

@moisses89 moisses89 left a comment

Choose a reason for hiding this comment

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

Just minor comments.

class PeriodAddressSerializer(serializers.Serializer):
start_date = serializers.SerializerMethodField()
end_date = serializers.SerializerMethodField()
holder = serializers.CharField(source="address")
Copy link
Member

Choose a reason for hiding this comment

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

We should return checksumed addresses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 5a58928 with gnosis.eth.django. serializers.EthereumAddressField

total_boosted_points = serializers.CharField()

def get_start_date(self, obj):
return obj.period.start_date
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in 7954e02.

Now accessing it via the source arg.

@@ -195,3 +196,30 @@ def get(self, *args, **kwargs):

serializer = self.serializer_class(queryset)
return Response(status=status.HTTP_200_OK, data=serializer.data)


class GetAddressPeriodsView(ListAPIView):
Copy link
Member

Choose a reason for hiding this comment

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

We could add cache_page here to don´t hit with every request the database.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 5a58928.

To keep it aligned with other endpoints I kept it with the same configuration. In the future we can consider having it as an application config 👍

Base automatically changed from use-decimal-in-factory to main June 12, 2024 15:30
@coveralls
Copy link

coveralls commented Jun 12, 2024

Pull Request Test Coverage Report for Build 9485475859

Details

  • 90 of 90 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.8%) to 91.663%

Totals Coverage Status
Change from base Build 9485440779: 0.8%
Covered Lines: 2056
Relevant Lines: 2243

💛 - Coveralls

@fmrsabino fmrsabino merged commit 2483257 into main Jun 12, 2024
5 checks passed
@fmrsabino fmrsabino deleted the get-address-periods branch June 12, 2024 19:53
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an endpoint to return period points.
3 participants