38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import django, os, sys
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'chunyu_project.settings'
|
|
django.setup()
|
|
from django.utils import timezone
|
|
from user.models import DailyCheckin, FUser, PointTransaction
|
|
from django.test import RequestFactory
|
|
from rest_framework_simplejwt.tokens import AccessToken
|
|
from user.views.wallet import CheckinStatusAPIView
|
|
|
|
today = timezone.localdate()
|
|
user = FUser.objects.get(id=2)
|
|
|
|
print(f"=== DB State ===")
|
|
print(f"Today: {today}")
|
|
print(f"User points: {user.points}")
|
|
records = DailyCheckin.objects.filter(user=user, checkin_date=today)
|
|
print(f"Records for today (ORM): {records.count()}")
|
|
print(f"Records SQL: {records.query}")
|
|
|
|
import MySQLdb
|
|
from django.conf import settings
|
|
db_conf = settings.DATABASES['default']
|
|
conn = MySQLdb.connect(host=db_conf['HOST'], port=int(db_conf['PORT']), user=db_conf['USER'], passwd=db_conf['PASSWORD'], db=db_conf['NAME'])
|
|
cursor = conn.cursor()
|
|
cursor.execute("SELECT id, user_id, checkin_date, created_at FROM user_dailycheckin WHERE user_id=2 AND checkin_date='2026-06-08'")
|
|
rows = cursor.fetchall()
|
|
print(f"Records for today (raw SQL): {rows}")
|
|
conn.close()
|
|
|
|
print(f"\n=== Simulate View ===")
|
|
from django.contrib.auth.models import AnonymousUser
|
|
factory = RequestFactory()
|
|
request = factory.get('/user/wallet/checkin/status/')
|
|
request.user = user
|
|
view = CheckinStatusAPIView.as_view()
|
|
response = view(request)
|
|
print(f"Response: {response.data}")
|