try to reduce save calls
This commit is contained in:
parent
15205875b2
commit
290f355b47
2 changed files with 2 additions and 6 deletions
|
@ -218,8 +218,8 @@ class Item(models.Model):
|
||||||
response = external_data('getData', {'id': self.itemId})
|
response = external_data('getData', {'id': self.itemId})
|
||||||
if response['status']['code'] == 200:
|
if response['status']['code'] == 200:
|
||||||
self.external_data = response['data']
|
self.external_data = response['data']
|
||||||
self.save()
|
|
||||||
self.make_poster(True)
|
self.make_poster(True)
|
||||||
|
self.save()
|
||||||
|
|
||||||
def expand_connections(self):
|
def expand_connections(self):
|
||||||
c = self.get('connections')
|
c = self.get('connections')
|
||||||
|
@ -817,7 +817,6 @@ class Item(models.Model):
|
||||||
update = True
|
update = True
|
||||||
if update:
|
if update:
|
||||||
self.rendered = False
|
self.rendered = False
|
||||||
self.save()
|
|
||||||
self.update_timeline()
|
self.update_timeline()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -943,7 +942,6 @@ class Item(models.Model):
|
||||||
if url:
|
if url:
|
||||||
data = ox.net.readUrl(url)
|
data = ox.net.readUrl(url)
|
||||||
self.poster.save('poster.jpg', ContentFile(data))
|
self.poster.save('poster.jpg', ContentFile(data))
|
||||||
self.save()
|
|
||||||
elif os.path.exists(poster):
|
elif os.path.exists(poster):
|
||||||
with open(poster) as f:
|
with open(poster) as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
@ -1006,7 +1004,6 @@ class Item(models.Model):
|
||||||
if frames:
|
if frames:
|
||||||
heat = [ox.image.getImageHeat(f['path']) for f in frames]
|
heat = [ox.image.getImageHeat(f['path']) for f in frames]
|
||||||
self.poster_frame = heat.index(max(heat))
|
self.poster_frame = heat.index(max(heat))
|
||||||
self.save()
|
|
||||||
|
|
||||||
def get_poster_frame_path(self):
|
def get_poster_frame_path(self):
|
||||||
frames = self.poster_frames()
|
frames = self.poster_frames()
|
||||||
|
@ -1034,7 +1031,6 @@ class Item(models.Model):
|
||||||
cmd += ['-f', frame]
|
cmd += ['-f', frame]
|
||||||
p = subprocess.Popen(cmd)
|
p = subprocess.Popen(cmd)
|
||||||
p.wait()
|
p.wait()
|
||||||
self.save()
|
|
||||||
icons = os.path.abspath(os.path.join(settings.MEDIA_ROOT, icon))
|
icons = os.path.abspath(os.path.join(settings.MEDIA_ROOT, icon))
|
||||||
icons = glob(icons.replace('.jpg', '*.jpg'))
|
icons = glob(icons.replace('.jpg', '*.jpg'))
|
||||||
for f in filter(lambda p: not p.endswith('/icon.jpg'), icons):
|
for f in filter(lambda p: not p.endswith('/icon.jpg'), icons):
|
||||||
|
|
|
@ -17,7 +17,7 @@ def update_poster(itemId):
|
||||||
item = models.Item.objects.get(itemId=itemId)
|
item = models.Item.objects.get(itemId=itemId)
|
||||||
item.make_poster(True)
|
item.make_poster(True)
|
||||||
item.make_icon()
|
item.make_icon()
|
||||||
|
item.save()
|
||||||
|
|
||||||
@task(ignore_resulsts=True, queue='default')
|
@task(ignore_resulsts=True, queue='default')
|
||||||
def update_external(itemId):
|
def update_external(itemId):
|
||||||
|
|
Loading…
Reference in a new issue