In [3]:
import os, sys
sys.path.insert(0, '/home/trax/trax/website')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "trax.settings")
import django
django.setup()
from tracks.models import Track, Laptime
from players.models import Player
from events.models import *
from vehicles.models import *

Most recent laptimes


In [13]:
ALREADY_SEEN_UNTIL = 5947
t = Track.objects.get(title__icontains="KIFFLOM")
laps = Laptime.objects.filter(track=t, pk__gte=ALREADY_SEEN_UNTIL).order_by('-pk')
seen_users = []
for l in laps:
    if l.player in seen_users:
        continue
    else:
        print (l.player, l.pk, l.created)
        seen_users.append(l.player)


og_space_ghost 5947 2018-06-19 05:17:37.135001+00:00

In [3]:
l.link


Out[3]:
'https://ibb.co/iD9dtT'

In [4]:
t = Track.objects.get(title__icontains="KIFFLOM")
u = Player.objects.get(username='cronixx')
hle = Hotlapping.objects.get(pk=32)
print(t.title, u.username, hle.title)


FISH KIFFLOM Attack cronixx TEPCOTT Season 3 Registration

In [ ]:


In [6]:
laps = Laptime.objects.filter(player=u, track=t).order_by('-millis')
for lap in laps:
    hllt = lap.hotlappinglaptime_set.all()[0]
    print(hllt.pk, hllt.laptime_id, hllt.laptime.link)


1065 5800  https://www.gtaracing.net/tc3qualifying
1089 5824 https://www.gtaracing.net/e/hl/32/
1090 5825 http://prntscr.com/jt9u6t

In [8]:
Laptime.objects.filter(pk__in=[5824, 5800]).delete()


Out[8]:
(4,
 {'events.HotlappingLaptime': 2,
  'events.SSRParticipation': 0,
  'tracks.Laptime': 2})

In [17]:
hle = Hotlapping.objects.get(pk=32)

In [24]:
hle.title


Out[24]:
'TEPCOTT Season 3 Registration'

In [20]:
l = laps[1]

In [33]:
hllt = HotlappingLaptime.objects.all()[6]

In [35]:
hllt.approved, hllt.laptime, hllt.hotlapping.title


Out[35]:
(False, <Laptime: benimi FMJ>, 'Lap Time Legends Round 1')

In [ ]:


In [ ]:


In [37]:
for hll in laps:
    x, y = HotlappingLaptime.objects.get_or_create(approved=True, laptime=hll, hotlapping=hle)
    print (x, y)


HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True
HotlappingLaptime object True

In [6]:
u = Player.objects.get(username__icontains="the_cuunt")

In [4]:
u.username


Out[4]:
'esquzz'

In [7]:
u.username = 'esqy'
u.save()

In [ ]: