use timestamp from changelog
This commit is contained in:
parent
54636fbc63
commit
9cf8417c30
2 changed files with 12 additions and 10 deletions
|
@ -159,18 +159,16 @@ class Changelog(db.Model):
|
||||||
if keys:
|
if keys:
|
||||||
key = keys[0]
|
key = keys[0]
|
||||||
primary = [key, meta[key]]
|
primary = [key, meta[key]]
|
||||||
|
i.modified = ts2datetime(timestamp)
|
||||||
if primary:
|
if primary:
|
||||||
if not meta[key] and i.meta.get('primaryid', [''])[0] == key:
|
if not meta[key] and i.meta.get('primaryid', [''])[0] == key:
|
||||||
logger.debug('remove id mapping %s %s', i.id, primary)
|
logger.debug('remove id mapping %s %s', i.id, primary)
|
||||||
i.update_primaryid(*primary, scrape=False)
|
i.update_primaryid(*primary, scrape=False, modified=i.modified)
|
||||||
i.modified = ts2datetime(timestamp)
|
|
||||||
elif meta[key] and i.meta.get('primaryid') != primary:
|
elif meta[key] and i.meta.get('primaryid') != primary:
|
||||||
logger.debug('edit mapping %s %s', i.id, primary)
|
logger.debug('edit mapping %s %s', i.id, primary)
|
||||||
i.update_primaryid(*primary, scrape=False)
|
i.update_primaryid(*primary, scrape=False, modified=i.modified)
|
||||||
i.modified = ts2datetime(timestamp)
|
|
||||||
else:
|
else:
|
||||||
i.update_meta(meta)
|
i.update_meta(meta, modified=i.modified)
|
||||||
i.modified = ts2datetime(timestamp)
|
|
||||||
i.save()
|
i.save()
|
||||||
user.clear_smart_list_cache()
|
user.clear_smart_list_cache()
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -264,7 +264,7 @@ class Item(db.Model):
|
||||||
'title'
|
'title'
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_meta(self, data):
|
def update_meta(self, data, modified=None):
|
||||||
update = False
|
update = False
|
||||||
record = {}
|
record = {}
|
||||||
for key in self.meta_keys:
|
for key in self.meta_keys:
|
||||||
|
@ -279,13 +279,15 @@ class Item(db.Model):
|
||||||
update = True
|
update = True
|
||||||
if update:
|
if update:
|
||||||
self.update()
|
self.update()
|
||||||
self.modified = datetime.utcnow()
|
if not modified:
|
||||||
|
modified = datetime.utcnow()
|
||||||
|
self.modified = modified
|
||||||
self.save()
|
self.save()
|
||||||
user = state.user()
|
user = state.user()
|
||||||
if record and user in self.users:
|
if record and user in self.users:
|
||||||
Changelog.record(user, 'edititem', self.id, record)
|
Changelog.record(user, 'edititem', self.id, record)
|
||||||
|
|
||||||
def update_primaryid(self, key=None, id=None, scrape=True):
|
def update_primaryid(self, key=None, id=None, scrape=True, modified=None):
|
||||||
if key is None and id is None:
|
if key is None and id is None:
|
||||||
if 'primaryid' not in self.meta:
|
if 'primaryid' not in self.meta:
|
||||||
return
|
return
|
||||||
|
@ -313,7 +315,9 @@ class Item(db.Model):
|
||||||
if scrape:
|
if scrape:
|
||||||
self.scrape()
|
self.scrape()
|
||||||
self.update_icons()
|
self.update_icons()
|
||||||
self.modified = datetime.utcnow()
|
if not modified:
|
||||||
|
modified = datetime.utcnow()
|
||||||
|
self.modified = modified
|
||||||
self.save()
|
self.save()
|
||||||
#if not scrape:
|
#if not scrape:
|
||||||
# Scrape.get_or_create(self.id)
|
# Scrape.get_or_create(self.id)
|
||||||
|
|
Loading…
Reference in a new issue