Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8b571dc
feat: index nadabot registry, provider and stamps
Prometheo Apr 30, 2024
d50632a
chore: add nadabot admin
Prometheo May 1, 2024
1579fb3
chore: review fixes: print to log, model fixes
Prometheo May 6, 2024
f99f868
filter registration by plCategories (#35)
Prometheo Jul 2, 2024
9dbe9a6
extend schema (#36)
Prometheo Jul 3, 2024
2f15218
add other tlds to cors whitelist (#38)
Prometheo Jul 4, 2024
5906bdd
test groups and rules
Prometheo Jul 6, 2024
7ed1403
add dev.local to cors allowed origins
lachlanglen Jul 8, 2024
12607cf
fix payout-setting error
lachlanglen Jul 8, 2024
897df4c
make PotPayout.paid_at nullable
lachlanglen Jul 8, 2024
0a0db66
fix sync db calls
lachlanglen Jul 8, 2024
b480a85
add awaits to async db methods
lachlanglen Jul 8, 2024
1556511
remove debug logs
lachlanglen Jul 8, 2024
d5871ea
add https://dev.local to cors allowed origins
lachlanglen Jul 8, 2024
1a19b17
Paginate by page (#39)
Prometheo Jul 8, 2024
9ea4d98
gunicorn graceful reload
lachlanglen Jul 8, 2024
c0008b3
fix after install script
lachlanglen Jul 8, 2024
ecd1ebe
add graceful gunicorn restart to testnet after install script
lachlanglen Jul 8, 2024
60a430a
avoid stopping services before migrations in after_install scripts
lachlanglen Jul 8, 2024
59dc627
Pagination limit and readme update (#40)
Prometheo Jul 9, 2024
e015252
add blacklist entry model
Prometheo Jul 10, 2024
6a07395
add https://dev.local back to cors allowed origins
lachlanglen Jul 10, 2024
0a78f1a
handle pot config update (#37)
Prometheo Jul 10, 2024
52229e1
review changes to model
Prometheo Jul 11, 2024
1432d1d
feat: index nadabot registry, provider and stamps
Prometheo Apr 30, 2024
d01e0db
chore: add nadabot admin
Prometheo May 1, 2024
083ba4b
chore: review fixes: print to log, model fixes
Prometheo May 6, 2024
e84dea5
test groups and rules
Prometheo Jul 6, 2024
56aff6c
add blacklist entry model
Prometheo Jul 10, 2024
79b72c1
review changes to model
Prometheo Jul 11, 2024
6428b87
fix conflict issues
Prometheo Jul 12, 2024
4a86812
Merge remote-tracking branch 'origin/new-nadabot-index' into new-nada…
Prometheo Jul 12, 2024
dc27873
fix provider onchain_id reference
Prometheo Jul 12, 2024
4c29abf
uncomment start block
Prometheo Jul 12, 2024
e394fce
add comment
Prometheo Jul 12, 2024
6a3a366
fix group indexing and test
Prometheo Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ media/

# Celery beat schedule file
celerybeat-schedule
dump.rdb

# Flask stuff:
instance/
Expand Down Expand Up @@ -99,7 +100,7 @@ poetry.lock
# dotenv
.env
.env.*

pyrightconfig.json
# virtualenv
.venv/
venv/
Expand Down Expand Up @@ -133,4 +134,4 @@ dmypy.json

# static

/static/
/static/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Possible Error Codes:

#### Pagination

Pagination available using `limit` and `offset` query params on endpoints that specify `paginated`. Default `limit` is 30.
Pagination available using `limit` and `page` as query param on endpoints that specify `paginated`. Default `limit` is 30.

Endpoints that support pagination will return a success response containing the following:

Expand Down Expand Up @@ -157,6 +157,7 @@ enum PotApplicationStatus {
#### ✅ Get registrations for list: `GET /lists/{LIST_ID}/registrations` (paginated)

Can specify status to filter by using `status` query param if desired, e.g. `status=Approved`
Can also specify project category to filter by using `category` query param if desired, e.g. `category=Education`

#### ✅ Get random registration for list: `GET /lists/{LIST_ID}/random_registration`

Expand Down
19 changes: 10 additions & 9 deletions accounts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
OpenApiTypes,
extend_schema,
)
from rest_framework.pagination import LimitOffsetPagination
from rest_framework.pagination import PageNumberPagination
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.views import APIView
Expand Down Expand Up @@ -41,9 +41,10 @@
AccountSerializer,
PaginatedAccountsResponseSerializer,
)
from api.pagination import ResultPagination


class DonorsAPI(APIView, LimitOffsetPagination):
class DonorsAPI(APIView, PageNumberPagination):

@extend_schema(
parameters=[
Expand Down Expand Up @@ -87,7 +88,7 @@ def get(self, request: Request, *args, **kwargs):
return self.get_paginated_response(serializer.data)


class AccountsListAPI(APIView, LimitOffsetPagination):
class AccountsListAPI(APIView, ResultPagination):

@extend_schema(
responses={
Expand Down Expand Up @@ -152,7 +153,7 @@ def get(self, request: Request, *args, **kwargs):
return Response(serializer.data)


class AccountActivePotsAPI(APIView, LimitOffsetPagination):
class AccountActivePotsAPI(APIView, PageNumberPagination):

@extend_schema(
parameters=[
Expand Down Expand Up @@ -208,7 +209,7 @@ def get(self, request: Request, *args, **kwargs):
return self.get_paginated_response(serializer.data)


class AccountPotApplicationsAPI(APIView, LimitOffsetPagination):
class AccountPotApplicationsAPI(APIView, PageNumberPagination):

@extend_schema(
parameters=[
Expand Down Expand Up @@ -262,7 +263,7 @@ def get(self, request: Request, *args, **kwargs):
return self.get_paginated_response(serializer.data)


class AccountDonationsReceivedAPI(APIView, LimitOffsetPagination):
class AccountDonationsReceivedAPI(APIView, PageNumberPagination):

@extend_schema(
parameters=[
Expand Down Expand Up @@ -302,7 +303,7 @@ def get(self, request: Request, *args, **kwargs):
return self.get_paginated_response(serializer.data)


class AccountDonationsSentAPI(APIView, LimitOffsetPagination):
class AccountDonationsSentAPI(APIView, PageNumberPagination):

@extend_schema(
parameters=[
Expand Down Expand Up @@ -342,7 +343,7 @@ def get(self, request: Request, *args, **kwargs):
return self.get_paginated_response(serializer.data)


class AccountPayoutsReceivedAPI(APIView, LimitOffsetPagination):
class AccountPayoutsReceivedAPI(APIView, PageNumberPagination):

@extend_schema(
parameters=[
Expand Down Expand Up @@ -376,7 +377,7 @@ def get(self, request: Request, *args, **kwargs):
{"message": f"Account with ID {account_id} not found."}, status=404
)

payouts = PotPayout.objects.filter(recipient=account)
payouts = PotPayout.objects.filter(recipient=account, paid_at__isnull=False)
results = self.paginate_queryset(payouts, request, view=self)
serializer = PotPayoutSerializer(results, many=True)
return self.get_paginated_response(serializer.data)
17 changes: 17 additions & 0 deletions accounts/migrations/0003_alter_account_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-07-12 12:15

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("accounts", "0002_account_near_social_profile_data"),
]

operations = [
migrations.AlterModelOptions(
name="account",
options={"ordering": ["id"]},
),
]
3 changes: 3 additions & 0 deletions accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class Account(models.Model):
help_text=_("NEAR social data contained under 'profile' key."),
)

class Meta:
ordering = ["id"]

async def fetch_near_social_profile_data_async(self):
fetch_profile_data = sync_to_async(self.fetch_near_social_profile_data)
await fetch_profile_data()
Expand Down
6 changes: 6 additions & 0 deletions api/pagination.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from rest_framework.pagination import PageNumberPagination

class ResultPagination(PageNumberPagination):
page_size = 30
page_size_query_param = 'limit'
max_page_size = 200
2 changes: 1 addition & 1 deletion base/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
extend_schema,
)
from rest_framework import serializers
from rest_framework.pagination import LimitOffsetPagination
from rest_framework.pagination import PageNumberPagination
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.views import APIView
Expand Down
2 changes: 1 addition & 1 deletion base/serializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from rest_framework import serializers


class TwoDecimalStringField(serializers.DecimalField):
class ResultPagination(serializers.DecimalField):
def to_representation(self, value):
if value is None:
return value
Expand Down
9 changes: 8 additions & 1 deletion base/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
SENTRY_DSN = os.environ.get("PL_SENTRY_DSN")

POTLOCK_TLA = "potlock.testnet" if ENVIRONMENT == "testnet" else "potlock.near"
NADABOT_TLA = "nadabot.testnet" if ENVIRONMENT == "testnet" else "nadabot.near"

NEAR_SOCIAL_CONTRACT_ADDRESS = (
"v1.social08.testnet" if ENVIRONMENT == "testnet" else "social.near"
Expand Down Expand Up @@ -102,12 +103,13 @@
"lists",
"pots",
"tokens",
"nadabot",
]

DEFAULT_PAGE_SIZE = 30

REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
"DEFAULT_PAGINATION_CLASS": "api.pagination.ResultPagination",
"PAGE_SIZE": DEFAULT_PAGE_SIZE,
"DEFAULT_THROTTLE_CLASSES": [
# "rest_framework.throttling.UserRateThrottle",
Expand Down Expand Up @@ -162,6 +164,11 @@
CORS_ALLOWED_ORIGINS = [
"http://localhost:3000",
"https://alpha.potlock.io",
"https://alpha.potlock.org",
"https://alpha.potlock.xyz",
"https://alpha.potlock.app", # regex matching might not be advisable.
"http://dev.local",
"https://dev.local",
]

# REDIS / CACHE CONFIGS
Expand Down
4 changes: 2 additions & 2 deletions donations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
OpenApiResponse,
extend_schema,
)
from rest_framework.pagination import LimitOffsetPagination
from rest_framework.pagination import PageNumberPagination
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.views import APIView
Expand All @@ -20,7 +20,7 @@
DONATE_CONTRACT = "donate." + settings.POTLOCK_TLA


class DonationContractConfigAPI(APIView, LimitOffsetPagination):
class DonationContractConfigAPI(APIView, PageNumberPagination):

@extend_schema(
responses={
Expand Down
Loading