incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1438224 - in /incubator/public/trunk/incuvoter: incuvoter.py votestatus.py
Date Thu, 24 Jan 2013 22:08:29 GMT
Author: brane
Date: Thu Jan 24 22:08:28 2013
New Revision: 1438224

URL: http://svn.apache.org/viewvc?rev=1438224&view=rev
Log:
Incuvoter: Notice cancelled votes as closed, and handle [DISCUSS][VOTE] tags.
Votestatus: Tag closed votes with canceleld or resolved status.

WARNING: Incompatible database schema change.

Modified:
    incubator/public/trunk/incuvoter/incuvoter.py
    incubator/public/trunk/incuvoter/votestatus.py

Modified: incubator/public/trunk/incuvoter/incuvoter.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/incuvoter/incuvoter.py?rev=1438224&r1=1438223&r2=1438224&view=diff
==============================================================================
--- incubator/public/trunk/incuvoter/incuvoter.py (original)
+++ incubator/public/trunk/incuvoter/incuvoter.py Thu Jan 24 22:08:28 2013
@@ -89,12 +89,13 @@ class FeedParser(object):
     __subject_rx = re.compile(
         # Skip anything before the first tag
         r'^[^[]*'
-        # A [RESULT] tag can come before the [VOTE] tag
-        r'(?P<firstres>\[RESULT\]\s*)?'
+        # A [RESULT] or [DISCUSS] or [CANCELLED] tag
+        # can come before the [VOTE] tag
+        r'(\[((?P<result1>RESULT)|DISCUSS|(?P<cancel1>CANCELL?(ED)?))\]\s*)?'
         # The [VOTE] tag is mandatory
-        r'(?P<vote>\[VOTE\]\s*)'
-        # Handle [VOTE][RESULT] as well, just in case
-        r'(?P<secondres>\[RESULT\]\s*)?'
+        r'\[VOTE\]\s*'
+        # Handle [VOTE][<tag>] as well, just in case
+        r'(?P<tag2>\[((?P<result2>RESULT)|DISCUSS|(?P<cancel2>CANCELL?(ED)?))\]\s*)?'
         # The rest of the subject line, and strip off trailing whitespace
         r'(?P<subject>.*?)\s*$',
         re.IGNORECASE)
@@ -118,7 +119,8 @@ class FeedParser(object):
                 sys.exit(1)
 
     ParsedVote = collections.namedtuple(
-        'ParsedVote', ('sortkey', 'updated', 'closed', 'subject'))
+        'ParsedVote',
+        ('sortkey', 'updated', 'subject', 'closed', 'cancelled'))
 
     def record(self, database):
         feed_updated = self.feed.get('updated', None)
@@ -148,20 +150,23 @@ class FeedParser(object):
             if updated and created and created > updated:
                 updated = created
             updated = timestring(updated)
-            if parsed.group('firstres') or parsed.group('secondres'):
+            cancelled = int(parsed.group('cancel1') is not None
+                            or parsed.group('cancel2') is not None)
+            if cancelled or parsed.group('result1') or parsed.group('result2'):
                 closed = updated
             else:
                 closed = None
 
-            votes.append(self.ParsedVote(subject.upper(),
-                                         updated, closed, subject))
+            votes.append(self.ParsedVote(subject.upper(), updated,
+                                         subject, closed, cancelled))
 
         # TODO: Filter duplicate votes, but return the first and
         #       last in every duplicate list
         database.record_votes(feed_updated,
                               (database.Vote(subject = v.subject,
                                              updated = v.updated,
-                                             closed = v.closed)
+                                             closed = v.closed,
+                                             cancelled = v.cancelled)
                                for v in sorted(votes)))
 
 
@@ -181,7 +186,8 @@ class FeedDatabase(object):
           subject TEXT NOT NULL,
           noticed TEXT NOT NULL,
           updated TEXT NOT NULL,
-          closed TEXT DEFAULT NULL
+          closed TEXT DEFAULT NULL,
+          cancelled INTEGER DEFAULT 0
         );
         CREATE INDEX updated_index ON vote(updated DESC);
         CREATE INDEX closed_index ON vote(closed DESC);
@@ -223,7 +229,8 @@ class FeedDatabase(object):
         return self.__updated
 
     class Vote(object):
-        __slots__ = ('sortkey', 'subject', 'noticed', 'updated', 'closed')
+        __slots__ = ('sortkey', 'subject',
+                     'noticed', 'updated', 'closed', 'cancelled')
 
         def __init__(self, **kwargs):
             for name in self.__slots__:
@@ -242,12 +249,14 @@ class FeedDatabase(object):
                 self.updated = other.updated
             if not self.closed:
                 self.closed = other.closed
+            if not self.cancelled:
+                self.cancelled = other.cancelled
 
         @classmethod
         def find(cls, con, subject):
             sortkey = subject.upper()
             cursor = con.cursor()
-            cursor.execute("SELECT subject, noticed, updated, closed"
+            cursor.execute("SELECT subject, noticed, updated, closed, cancelled"
                            " FROM vote WHERE sortkey = ?", (sortkey,))
             row = cursor.fetchone()
             if row is None:
@@ -260,17 +269,19 @@ class FeedDatabase(object):
             if self.noticed is None:
                 self.noticed = self.updated
             con.execute("INSERT INTO vote"
-                        " (sortkey, subject, noticed, updated, closed)"
-                        " VALUES (?, ?, ?, ?, ?)",
+                        " (sortkey, subject, noticed, updated, closed, cancelled)"
+                        " VALUES (?, ?, ?, ?, ?, ?)",
                         (self.sortkey, self.subject,
-                         self.noticed, self.updated, self.closed))
+                         self.noticed, self.updated, self.closed, self.cancelled))
 
         def update(self, con):
             assert self.sortkey is not None
             assert self.subject.upper() == self.sortkey
-            con.execute("UPDATE vote SET noticed = ?, updated = ?, closed = ?"
+            con.execute("UPDATE vote SET"
+                        " noticed = ?, updated = ?, closed = ?, cancelled = ?"
                         " WHERE sortkey = ?",
-                        (self.noticed, self.updated, self.closed, self.sortkey))
+                        (self.noticed, self.updated, self.closed,
+                         self.cancelled, self.sortkey))
 
     def record_votes(self, updated, votes):
         self.con.rollback()
@@ -297,10 +308,10 @@ class FeedDatabase(object):
 
     def __list_votes(self, active):
         if active:
-            sql = ("SELECT sortkey, subject, noticed, updated, closed"
+            sql = ("SELECT sortkey, subject, noticed, updated, closed, cancelled"
                    " FROM vote WHERE closed IS NULL ORDER BY updated DESC")
         else:
-            sql = ("SELECT sortkey, subject, noticed, updated, closed"
+            sql = ("SELECT sortkey, subject, noticed, updated, closed, cancelled"
                    " FROM vote WHERE closed IS NOT NULL ORDER BY closed DESC")
         cursor = self.con.cursor()
         cursor.execute(sql)

Modified: incubator/public/trunk/incuvoter/votestatus.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/incuvoter/votestatus.py?rev=1438224&r1=1438223&r2=1438224&view=diff
==============================================================================
--- incubator/public/trunk/incuvoter/votestatus.py (original)
+++ incubator/public/trunk/incuvoter/votestatus.py Thu Jan 24 22:08:28 2013
@@ -106,6 +106,7 @@ __closed_table = """\
   <h2>Recently Closed Votes</h2>
   <table>
     <tr>
+     <th>Status</th>
      <th>Subject</th>
      <th>Started</th>
      <th>Closed</th>
@@ -115,6 +116,7 @@ __closed_table = """\
 
 __closed_row = """\
     <tr class="%(klass)s">
+      <td>%(status)s</td>
       <td>%(subject)s</td>
       <td>%(noticed)s</td>
       <td>%(closed)s</td>
@@ -162,6 +164,7 @@ def refresh_page(target, database):
             klass = 'normal'
         resolved.append(__closed_row
                         % dict(klass = klass,
+                               status = vote.cancelled and 'Cancelled' or 'Resolved',
                                subject = cgi.escape(vote.subject),
                                noticed = __datescape(noticed),
                                closed = __datescape(closed)))



---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message