Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ media/
# Celery beat schedule file
celerybeat-schedule
dump.rdb
celerybeat-schedule.db

# Flask stuff:
instance/
Expand Down Expand Up @@ -135,3 +136,5 @@ dmypy.json
# static

/static/

.DS_Store
30 changes: 15 additions & 15 deletions base/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
app.autodiscover_tasks()

app.conf.beat_schedule = {
"update_account_statistics_every_5_minutes": {
"task": "indexer_app.tasks.update_account_statistics",
"schedule": crontab(minute="*/5"), # Executes every 5 minutes
"options": {"queue": "beat_tasks"},
},
"fetch_usd_prices_every_5_minutes": {
"task": "indexer_app.tasks.fetch_usd_prices",
"schedule": crontab(minute="*/5"), # Executes every 5 minutes
"options": {"queue": "beat_tasks"},
},
"update_pot_statistics_every_5_minutes": {
"task": "indexer_app.tasks.update_pot_statistics",
"schedule": crontab(minute="*/5"), # Executes every 5 minutes
"options": {"queue": "beat_tasks"},
},
# "update_account_statistics_every_5_minutes": {
# "task": "indexer_app.tasks.update_account_statistics",
# "schedule": crontab(minute="*/5"), # Executes every 5 minutes
# "options": {"queue": "beat_tasks"},
# },
# "fetch_usd_prices_every_5_minutes": {
# "task": "indexer_app.tasks.fetch_usd_prices",
# "schedule": crontab(minute="*/5"), # Executes every 5 minutes
# "options": {"queue": "beat_tasks"},
# },
# "update_pot_statistics_every_5_minutes": {
# "task": "indexer_app.tasks.update_pot_statistics",
# "schedule": crontab(minute="*/5"), # Executes every 5 minutes
# "options": {"queue": "beat_tasks"},
# },
"fetch_stellar_events_every_minute": {
"task": "indexer_app.tasks.stellar_event_indexer",
"schedule": crontab(minute="*/1"), # Executes every 1 minutes
Expand Down
57 changes: 40 additions & 17 deletions base/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@

# SECURITY WARNING: keep the secret key used in production secret!
# TODO: update before prod release
SECRET_KEY = os.environ.get("PL_DJANGO_SECRET_KEY", "django-insecure-=r_v_es6w6rxv42^#kc2hca6p%=fe_*cog_5!t%19zea!enlju")
SECRET_KEY = os.environ.get(
"PL_DJANGO_SECRET_KEY",
"django-insecure-=r_v_es6w6rxv42^#kc2hca6p%=fe_*cog_5!t%19zea!enlju",
)

ALLOWED_HOSTS = [
"ec2-100-27-57-47.compute-1.amazonaws.com",
"ec2-44-208-38-31.compute-1.amazonaws.com",
"127.0.0.1",
"dev.potlock.io",
"test-dev.potlock.io",
"api.potlock.io"
"api.potlock.io",
# "alpha.potlock.io",
]

Expand All @@ -62,28 +65,45 @@
RECLAIM_APP_ID = os.environ.get("PL_RECLAIM_APP_ID")
RECLAIM_APP_SECRET = os.environ.get("PL_RECLAIM_APP_SECRET")
RECLAIM_TWITTER_PROVIDER_ID = os.environ.get("PL_RECLAIM_TWITTER_PROVIDER_ID")
INDEXER_STREAMER_WAIT_TIME = os.environ.get("PL_INDEXER_STREAMER_WAIT_TIME", 300) # in seconds
INDEXER_STREAMER_WAIT_TIME = os.environ.get(
"PL_INDEXER_STREAMER_WAIT_TIME", 300
) # in seconds

# POTLOCK_TLA = "potlock.testnet" if ENVIRONMENT == "testnet" else "potlock.near"
POTLOCK_TLA = "potlock.testnet" if ENVIRONMENT == "testnet" else ("staging.potlock.near" if ENVIRONMENT == "dev" else "potlock.near")
POTLOCK_TLA = (
"potlock.testnet"
if ENVIRONMENT == "testnet"
else ("staging.potlock.near" if ENVIRONMENT == "dev" else "potlock.near")
)
# NADABOT_TLA = "nadabot.testnet" if ENVIRONMENT == "testnet" else "nadabot.near"
NADABOT_TLA = "nadabot.testnet" if ENVIRONMENT == "testnet" else ("staging.nadabot.near" if ENVIRONMENT == "dev" else "nadabot.near")
NADABOT_TLA = (
"nadabot.testnet"
if ENVIRONMENT == "testnet"
else ("staging.nadabot.near" if ENVIRONMENT == "dev" else "nadabot.near")
)
STELLAR_CONTRACT_ID = os.environ.get("PL_STELLAR_CONTRACT_ID", "")
STELLAR_PROJECTS_REGISTRY_CONTRACT = os.environ.get("PL_STELLAR_PROJECTS_REGISTRY_CONTRACT", "")
STELLAR_PROJECTS_REGISTRY_CONTRACT = os.environ.get(
"PL_STELLAR_PROJECTS_REGISTRY_CONTRACT", ""
)
STELLAR_LIST_CONTRACT = os.environ.get("PL_STELLAR_LIST_CONTRACT", "")
NEAR_SOCIAL_CONTRACT_ADDRESS = (
"v1.social08.testnet" if ENVIRONMENT == "testnet" else "social.near"
)
NEAR_GRANTPICKS_CONTRACT_ID = "v2.grantpicks.potlock.testnet" if ENVIRONMENT == "testnet" else ("" if ENVIRONMENT == "dev" else "")
NEAR_GRANTPICKS_CONTRACT_ID = (
"v2.grantpicks.potlock.testnet"
if ENVIRONMENT == "testnet"
else ("" if ENVIRONMENT == "dev" else "")
)
# TODO: split settigns file by enviroment
if ENVIRONMENT == "testnet":
POTLOCK_PATTERN = r'\.potlock\.testnet$'
NADABOT_PATTERN = r'\.nadabot\.testnet$'
POTLOCK_PATTERN = r"\.potlock\.testnet$"
NADABOT_PATTERN = r"\.nadabot\.testnet$"
elif ENVIRONMENT == "dev":
POTLOCK_PATTERN = r'\.staging\.potlock\.near$'
NADABOT_PATTERN = r'\.staging\.nadabot\.near$'
POTLOCK_PATTERN = r"\.staging\.potlock\.near$"
NADABOT_PATTERN = r"\.staging\.nadabot\.near$"
else: # mainnet/prod
POTLOCK_PATTERN = r'(?<!\.staging)\.potlock\.near$'
NADABOT_PATTERN = r'(?<!\.staging)\.nadabot\.near$'
POTLOCK_PATTERN = r"(?<!\.staging)\.potlock\.near$"
NADABOT_PATTERN = r"(?<!\.staging)\.nadabot\.near$"

FASTNEAR_RPC_URL = (
"https://rpc.web4.testnet.page"
Expand Down Expand Up @@ -133,7 +153,7 @@
"nadabot",
"chains",
"grantpicks",
"campaigns"
"campaigns",
]

DEFAULT_PAGE_SIZE = 30
Expand Down Expand Up @@ -205,7 +225,7 @@
"https://testnet.potlock.org",
"https://testnet.potlock.xyz",
"https://testnet.potlock.app",
"https://testnet.potlock.io"
"https://testnet.potlock.io",
]
elif ENVIRONMENT == "dev":
CORS_ALLOWED_ORIGINS = [
Expand All @@ -216,6 +236,9 @@
"https://dev.local",
"https://app.potlock.app",
"https://app.potlock.org",
"http://alpha.potlock.org",
"https://alpha.potlock.xyz",
"https://alpha.potlock.app",
]
else:
CORS_ALLOWED_ORIGINS = [
Expand All @@ -242,14 +265,14 @@
"https://bos.potlock.io",
"https://app.potlock.io",
"https://bos.potlock.app",
"https://app.potlock.app"
"https://app.potlock.app",
]

CORS_ALLOWED_ORIGIN_REGEXES = [
"^https:\/\/potlock-next-[\w-]+-potlock\.vercel\.app\/?$",
"^https?:\/\/.*\.?grantpicks\.com$",
"^https:\/\/staging\.app\.potlock\.(org|io|xyz|app)\/?$",
"^https:\/\/staging\.alpha\.potlock\.(org|io|xyz|app)\/?$"
"^https:\/\/staging\.alpha\.potlock\.(org|io|xyz|app)\/?$",
]

# REDIS / CACHE CONFIGS
Expand Down
12 changes: 4 additions & 8 deletions grantpicks/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class RoundsListAPI(APIView, CustomSizePageNumberPagination):
500: OpenApiResponse(description="Internal server error"),
},
)
@method_decorator(cache_page(60 * 1))
def get(self, request: Request, *args, **kwargs):
account_id = kwargs.get("account_id")
if account_id:
Expand Down Expand Up @@ -136,11 +135,10 @@ class RoundDetailAPI(APIView):
404: OpenApiResponse(description="Round not found"),
},
)
@method_decorator(cache_page(60 * 1))
def get(self, request: Request, *args, **kwargs):
round_id = kwargs.get("round_id")
try:
round = Round.objects.get(id=round_id)
round = Round.objects.get(on_chain_id=round_id)
except Round.DoesNotExist:
return Response({"message": f"Round with ID {round_id} not found."}, status=404)
serializer = RoundSerializer(round)
Expand Down Expand Up @@ -171,11 +169,10 @@ class RoundApplicationsAPI(APIView, CustomSizePageNumberPagination):
404: OpenApiResponse(description="Round not found"),
},
)
@method_decorator(cache_page(60 * 1))
def get(self, request: Request, *args, **kwargs):
round_id = kwargs.get("round_id")
try:
round = Round.objects.get(id=round_id)
round = Round.objects.get(on_chain_id=round_id)
except Round.DoesNotExist:
return Response({"message": f"Round with ID {round_id} not found."}, status=404)

Expand Down Expand Up @@ -210,12 +207,11 @@ class ProjectRoundVotesAPI(APIView, CustomSizePageNumberPagination):
404: OpenApiResponse(description="Round or project not found"),
},
)
@method_decorator(cache_page(60 * 1))
def get(self, request: Request, *args, **kwargs):
round_id = kwargs.get("round_id")
project_id = kwargs.get("project_id") # Get project_id from kwargs
try:
round_obj = Round.objects.get(id=round_id)
round_obj = Round.objects.get(on_chain_id=round_id)
# project = Project.objects.get(id=project_id) # comment out now, might use later if decide to return vote pairs instead
except Round.DoesNotExist:
return Response({"message": f"Round with ID {round_id} not found."}, status=404)
Expand Down Expand Up @@ -278,7 +274,7 @@ class ProjectListAPI(APIView, CustomSizePageNumberPagination):
500: OpenApiResponse(description="Internal server error"),
},
)
@method_decorator(cache_page(60 * 5))
@method_decorator(cache_page(60 * 2))
def get(self, request: Request, *args, **kwargs):
projects = Project.objects.all()
status_param = request.query_params.get("status")
Expand Down
18 changes: 18 additions & 0 deletions grantpicks/migrations/0010_alter_project_video_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.6 on 2025-10-10 22:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("grantpicks", "0009_round_minimum_deposit"),
]

operations = [
migrations.AlterField(
model_name="project",
name="video_url",
field=models.URLField(blank=True, null=True),
),
]
Loading
Loading