Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
spacepatcher committed Dec 27, 2017
2 parents 2ca03c6 + bc8b866 commit 65afc37
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/modules/db_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ def db_update_removed(self, feed_data):
current_time_db = datetime.now()
current_time_json = current_time_db.isoformat()
for ip in ip_group:
select_query = select([feed_table.c.timeline]).where(feed_table.c.ip == ip)
timeline_list = db_session.execute(select_query).fetchone()[0]
period_json = timeline_list.pop()
period_json["removed"] = current_time_json
timeline_list.append(period_json)
update_query = update(feed_table).where(feed_table.c.ip == ip).values(last_removed=current_time_db,
timeline=timeline_list)
db_session.execute(update_query)
if db_session.query((exists().where(feed_table.c.ip == ip))).scalar():
select_query = select([feed_table.c.timeline]).where(feed_table.c.ip == ip)
timeline_list = db_session.execute(select_query).fetchone()[0]
period_json = timeline_list.pop()
period_json["removed"] = current_time_json
timeline_list.append(period_json)
update_query = update(feed_table).where(feed_table.c.ip == ip).values(last_removed=current_time_db,
timeline=timeline_list)
db_session.execute(update_query)
db_session.commit()
except Exception as e:
self.logger.error("Error: {}".format(e))
Expand Down

0 comments on commit 65afc37

Please sign in to comment.