Skip to content
Snippets Groups Projects
Commit 499a2e99 authored by Branson Stephens's avatar Branson Stephens
Browse files

calculating next log number N by taking the max of N's already in the database.

parent 37bf9981
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ import datetime
import thread
import string
import os
import logging
# XXX ER2.utils. utils is in project directory. ugh.
from utils import posixToGpsTime
......@@ -200,6 +200,7 @@ class EventLog(models.Model):
issuer = models.ForeignKey(User)
filename = models.CharField(max_length=100, default="")
comment = models.TextField(null=False)
#XXX Does this need to be indexed for better performance?
N = models.IntegerField(null=False)
def fileurl(self):
......@@ -219,7 +220,7 @@ class EventLog(models.Model):
while (not success and attempts < 5):
attempts = attempts + 1
if self.event.eventlog_set.count():
self.N = event.eventlog_set.order_by('-N')[0].N + 1
self.N = int(self.event.eventlog_set.aggregate(models.Max('N'))['N__max']) + 1
else:
self.N = 1
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment