From 263d4ec192e187973d7e404a65b4c358979f4657 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sun, 20 May 2018 12:45:30 -0500 Subject: [PATCH] Move the task creation detection code above the comment detection code, and don't run the latter if the former is true. --- lugito | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lugito b/lugito index 232a5dd..6cbb7dc 100755 --- a/lugito +++ b/lugito @@ -84,35 +84,37 @@ def main(): taskexists = False if taskexists: - commentid = None - edited = False - # Let's see if this was a comment and if it's just an edit + # First, let's see if it's a new task + newcomment = False + epoch = False for task in tasksearch: - dataepoch = data["action"]["epoch"] - datemodified = task["dateModified"] - if datemodified >= (dataepoch - 10) and datemodified <= (dataepoch + 10) and task["comments"] != []: - comment = True - commentid = task["id"] - if datemodified != task["dateCreated"]: - edited = True + if epoch: + if task["dateCreated"] == task["dateModified"] and task["dateCreated"] == epoch: + newcomment = True else: - edited = False - break + newcomment = False + break else: - comment = False + epoch = task["dateCreated"] - newcomment = False - epoch = False - if not comment and not edited: + # If it's not a new task, let's see if it's a comment, and if it's just an edit + if not newcomment: + commentid = None + edited = False for task in tasksearch: - if epoch: - if task["dateCreated"] == task["dateModified"] and task["dateCreated"] == epoch: - newcomment = True + dataepoch = data["action"]["epoch"] + datemodified = task["dateModified"] + if datemodified >= (dataepoch - 10) and datemodified <= (dataepoch + 10) and task["comments"] != []: + comment = True + commentid = task["id"] + if datemodified != task["dateCreated"]: + edited = True else: - newcomment = False - break + edited = False + break else: - epoch = task["dateCreated"] + comment = False + # We should also know who did this thing userlookup = tasksearch[0]["authorPHID"]