Fix path_order => serial_number

This commit is contained in:
2025-08-29 18:09:32 +09:00
parent 8a73840298
commit 5fff127faf
5 changed files with 19 additions and 24 deletions

View File

@ -914,11 +914,6 @@ class Checkpoint(models.Model):
class GpsCheckin(models.Model): class GpsCheckin(models.Model):
id = models.AutoField(primary_key=True) # 明示的にidフィールドを追加 id = models.AutoField(primary_key=True) # 明示的にidフィールドを追加
path_order = models.IntegerField(
null=False,
default=0,
help_text="チェックポイントの順序番号"
)
zekken = models.CharField( zekken = models.CharField(
max_length=20, max_length=20,
null=True, null=True,
@ -1087,13 +1082,13 @@ class GpsCheckin(models.Model):
class Meta: class Meta:
db_table = 'rog_gpscheckin' # 実際のテーブル名に合わせて修正 db_table = 'rog_gpscheckin' # 実際のテーブル名に合わせて修正
indexes = [ indexes = [
models.Index(fields=['zekken', 'event_code', 'path_order'], name='idx_zekken_event'), models.Index(fields=['zekken', 'event_code', 'serial_number'], name='idx_zekken_event'),
models.Index(fields=['create_at'], name='idx_create_at'), models.Index(fields=['create_at'], name='idx_create_at'),
] ]
def __str__(self): def __str__(self):
return f"{self.event_code}-{self.zekken_number}-{self.path_order}-buy:{self.buy_flag}-valid:{self.validate_location}-point:{self.points}" return f"{self.event_code}-{self.zekken_number}-{self.serial_number}-buy:{self.buy_flag}-valid:{self.validate_location}-point:{self.points}"
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
# 作成時・更新時のタイムスタンプを自動設定 # 作成時・更新時のタイムスタンプを自動設定

View File

@ -2661,9 +2661,9 @@ def get_checkins(request, *args, **kwargs):
# チェックインデータの取得とCP情報の結合 # チェックインデータの取得とCP情報の結合
checkins = GpsCheckin.objects.filter( checkins = GpsCheckin.objects.filter(
zekken_number=zekken_number, zekken=zekken_number,
event_code=event_code event_code=event_code
).order_by('path_order') ).order_by('serial_number')
data = [] data = []
for c in checkins: for c in checkins:
@ -2687,7 +2687,7 @@ def get_checkins(request, *args, **kwargs):
data.append({ data.append({
'id': c.id, 'id': c.id,
'path_order': c.path_order, 'path_order': c.serial_number,
'cp_number': c.cp_number, 'cp_number': c.cp_number,
'sub_loc_id': location.sub_loc_id if location else f"#{c.cp_number}", 'sub_loc_id': location.sub_loc_id if location else f"#{c.cp_number}",
'location_name': location.location_name if location else None, 'location_name': location.location_name if location else None,
@ -2731,7 +2731,7 @@ def update_checkins(request):
logger.info(f"Updating existing checkin: {checkin}") logger.info(f"Updating existing checkin: {checkin}")
# 既存レコードの更新 # 既存レコードの更新
checkin.path_order = update['order'] checkin.serial_number = update['order']
checkin.buy_flag = update.get('buy_flag', False) checkin.buy_flag = update.get('buy_flag', False)
checkin.validate_location = update.get('validation', False) checkin.validate_location = update.get('validation', False)
checkin.points = update.get('points', 0) checkin.points = update.get('points', 0)
@ -2750,9 +2750,9 @@ def update_checkins(request):
logger.info(f"Creating new checkin: {update}") logger.info(f"Creating new checkin: {update}")
try: try:
checkin = GpsCheckin.objects.create( checkin = GpsCheckin.objects.create(
zekken_number=zekken_number, zekken=zekken_number,
event_code=event_code, event_code=event_code,
path_order=update['order'], serial_number=update['order'],
cp_number=update['cp_number'], cp_number=update['cp_number'],
validate_location=update.get('validation', False), validate_location=update.get('validation', False),
buy_flag=update.get('buy_flag', False), buy_flag=update.get('buy_flag', False),
@ -2770,14 +2770,14 @@ def update_checkins(request):
# 更新後のデータを順序付けて取得 # 更新後のデータを順序付けて取得
updated_checkins = GpsCheckin.objects.filter( updated_checkins = GpsCheckin.objects.filter(
zekken_number=zekken_number, zekken=zekken_number,
event_code=event_code event_code=event_code
).order_by('path_order') ).order_by('serial_number')
return Response({ return Response({
'status': 'success', 'status': 'success',
'message': 'Checkins updated successfully', 'message': 'Checkins updated successfully',
'data': [{'id': c.id, 'path_order': c.path_order} for c in updated_checkins] 'data': [{'id': c.id, 'path_order': c.serial_number} for c in updated_checkins]
}) })
except Exception as e: except Exception as e:
@ -2806,7 +2806,7 @@ def update_checkins_old(request):
logger.info(f"Updating existing checkin: {checkin}") logger.info(f"Updating existing checkin: {checkin}")
# 既存レコードの更新 # 既存レコードの更新
checkin.path_order = update['order'] checkin.serial_number = update['order']
checkin.buy_flag = update.get('buy_flag', False) checkin.buy_flag = update.get('buy_flag', False)
checkin.validate_location = update.get('validation', False) checkin.validate_location = update.get('validation', False)
checkin.points = update.get('points', 0) checkin.points = update.get('points', 0)
@ -2825,10 +2825,10 @@ def update_checkins_old(request):
logger.info("Creating new checkin:{update}") logger.info("Creating new checkin:{update}")
try: try:
checkin = GpsCheckin.objects.create( checkin = GpsCheckin.objects.create(
zekken_number=update_base['zekken_number'], zekken=update_base['zekken_number'],
event_code=update_base['event_code'], event_code=update_base['event_code'],
path_order=update['order'], serial_number=update['order'],
cp_number=update['cp_number'], cp_number=update['cp_number'],
validate_location=update.get('validation', False), validate_location=update.get('validation', False),
buy_flag=update.get('buy_flag', False), buy_flag=update.get('buy_flag', False),

View File

@ -213,13 +213,13 @@ def get_participant_validation_details(request):
checkins = GpsCheckin.objects.filter( checkins = GpsCheckin.objects.filter(
zekken=str(zekken_number), zekken=str(zekken_number),
event_code=event_code event_code=event_code
).order_by('path_order') ).order_by('serial_number')
checkin_details = [] checkin_details = []
for checkin in checkins: for checkin in checkins:
checkin_details.append({ checkin_details.append({
'id': checkin.id, 'id': checkin.id,
'path_order': checkin.path_order, 'path_order': checkin.serial_number,
'cp_number': checkin.cp_number, 'cp_number': checkin.cp_number,
'checkin_time': checkin.create_at.isoformat() if checkin.create_at else None, 'checkin_time': checkin.create_at.isoformat() if checkin.create_at else None,
'image_url': checkin.image_address, 'image_url': checkin.image_address,

View File

@ -196,7 +196,7 @@ def bulk_upload_photos(request):
zekken_number=str(zekken_number), zekken_number=str(zekken_number),
event_code=event_code, event_code=event_code,
cp_number=checkpoint.cp_number, cp_number=checkpoint.cp_number,
path_order=existing_count + 1, serial_number=existing_count + 1,
lattitude=gps_info['latitude'], lattitude=gps_info['latitude'],
longitude=gps_info['longitude'], longitude=gps_info['longitude'],
image_address=s3_url, image_address=s3_url,

View File

@ -181,7 +181,7 @@ def get_team_photos(zekken_number, event_code):
image_address__isnull=False image_address__isnull=False
).exclude( ).exclude(
image_address='' image_address=''
).order_by('path_order', 'create_at') ).order_by('serial_number', 'create_at')
logger.info(f"Found {gps_checkins.count()} GPS checkins with images") logger.info(f"Found {gps_checkins.count()} GPS checkins with images")
@ -203,7 +203,7 @@ def get_team_photos(zekken_number, event_code):
"cp_number": gps.cp_number if gps.cp_number is not None else 0, "cp_number": gps.cp_number if gps.cp_number is not None else 0,
"photo_url": image_url, "photo_url": image_url,
"checkin_time": gps.create_at.strftime("%Y-%m-%d %H:%M:%S") if gps.create_at else None, "checkin_time": gps.create_at.strftime("%Y-%m-%d %H:%M:%S") if gps.create_at else None,
"path_order": gps.path_order, "path_order": gps.serial_number,
"buy_flag": gps.buy_flag, "buy_flag": gps.buy_flag,
"validate_location": gps.validate_location, "validate_location": gps.validate_location,
"points": gps.points "points": gps.points