Browse Source

Store time data as actual datetime objects instead of UNIX time.

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
18d451974d
3 changed files with 17 additions and 13 deletions
  1. +1
    -1
      earwigbot/tasks/afc_statistics.py
  2. +12
    -8
      earwigbot/tasks/drn_clerkbot.py
  3. +4
    -4
      earwigbot/tasks/schema/drn_clerkbot.sql

+ 1
- 1
earwigbot/tasks/afc_statistics.py View File

@@ -723,7 +723,7 @@ class AFCStatistics(Task):
if "D" in statuses and chart != self.CHART_MISPLACE:
notes += "|nr=1" # Submission was resubmitted

time_since_modify = (datetime.now() - m_time).total_seconds()
time_since_modify = (datetime.utcnow() - m_time).total_seconds()
max_time = 4 * 24 * 60 * 60
if time_since_modify > max_time:
notes += "|no=1" # Submission hasn't been touched in over 4 days


+ 12
- 8
earwigbot/tasks/drn_clerkbot.py View File

@@ -197,8 +197,9 @@ class DRNClerkBot(Task):
f_time = datetime.strptime(strp, match.group(2))
else:
f_user, f_time = None, datetime.utcnow()
zero = datetime.min
case = _Case(id_, title, status, self.STATUS_UNKNOWN, f_user,
f_time, "", 0, "", 0, 0, False, False, 0,
f_time, "", zero, "", zero, zero, False, False, 0,
new=True)
cases.append(case)
else:
@@ -287,7 +288,8 @@ class DRNClerkBot(Task):
if case.last_action != self.STATUS_NEEDASSIST:
case.status = self.STATUS_NEEDASSIST
timestamps = [timestamp for (editor, timestamp) in signatures]
if time() - max(timestamps) > 60 * 60 * 24 * 2:
age = (datetime.utcnow() - max(timestamps)).total_seconds()
if age > 60 * 60 * 24 * 2:
if case.last_action != self.STATUS_STALE:
case.status = self.STATUS_STALE
return []
@@ -307,7 +309,8 @@ class DRNClerkBot(Task):
return []

def clerk_review_case(self, case):
if time() - case.file_time > 60 * 60 * 24 * 7:
age = (datetime.utcnow() - case.file_time).total_seconds()
if age > 60 * 60 * 24 * 7:
if not case.very_old_notified:
template = "{{subst:" + self.tl_notify_stale
template += case.title.replace("|", "|") + "}}"
@@ -318,11 +321,11 @@ class DRNClerkBot(Task):

def clerk_closed_case(self, case, signatures):
if not case.close_time:
case.close_time = time()
case.close_time = datetime.utcnow()
timestamps = [timestamp for (editor, timestamp) in signatures]
closed_long_ago = time() - case.close_time > 60 * 60 * 24
modified_long_ago = time() - max(timestamps) > 60 * 60 * 24
if closed_long_ago and modified_long_ago:
close_age = (datetime.utcnow() - case.close_time).total_seconds()
modify_age = (datetime.utcnow() - max(timestamps)).total_seconds()
if closed_age > 60 * 60 * 24 and modify_age > 60 * 60 * 24:
case.status = self.STATUS_ARCHIVE
case.body = "{{" + self.tl_archive_top + "}}\n" + case.body
case.body += "\n{{" + self.tl_archive_bottom + "}}"
@@ -330,7 +333,8 @@ class DRNClerkBot(Task):
case.body = re.sub(reg, "", case.body)

def check_for_review(self, case):
if time() - case.file_time > 60 * 60 * 24 * 4:
age = (datetime.utcnow() - case.file_time).total_seconds()
if age > 60 * 60 * 24 * 4:
if case.last_action != self.STATUS_REVIEW:
case.status = self.STATUS_REVIEW



+ 4
- 4
earwigbot/tasks/schema/drn_clerkbot.sql View File

@@ -19,12 +19,12 @@ CREATE TABLE `case` (
`case_status` int(2) unsigned DEFAULT NULL,
`case_last_action` int(2) unsigned DEFAULT NULL,
`case_file_user` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`case_file_time` int(10) unsigned DEFAULT NULL,
`case_file_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`case_modify_user` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`case_modify_time` int(10) unsigned DEFAULT NULL,
`case_modify_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`case_volunteer_user` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`case_volunteer_time` int(10) unsigned DEFAULT NULL,
`case_close_time` int(10) unsigned DEFAULT NULL,
`case_volunteer_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`case_close_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`case_parties_notified` tinyint(1) unsigned DEFAULT NULL,
`case_very_old_notified` tinyint(1) unsigned DEFAULT NULL,
`case_last_volunteer_size` int(9) unsigned DEFAULT NULL,


Loading…
Cancel
Save