#1094 Closed at in issues
Merged 7 years ago by pingou. Opened 7 years ago by vivekanand1101.
vivekanand1101/pagure created_at  into  master

@@ -0,0 +1,27 @@ 

+ """add_closed_at_attribute_in_issues

+ 

+ Revision ID: 43df5e588a87

+ Revises: 22db0a833d35

+ Create Date: 2016-06-28 22:59:36.653905

+ 

+ """

+ 

+ # revision identifiers, used by Alembic.

+ revision = '43df5e588a87'

+ down_revision = '22db0a833d35'

+ 

+ from alembic import op

+ import sqlalchemy as sa

+ 

+ 

+ def upgrade():

+     ''' Add closed_at column in issues table '''

+     op.add_column(

+             'issues',

+             sa.Column('closed_at', sa.DateTime, nullable=True)

+     )

+ 

+ 

+ def downgrade():

+     ''' Remove the closed_at column in issues table '''

+     op.drop_column('issues', 'closed_at')

file modified
+2
@@ -1231,6 +1231,8 @@ 

          edit.append('content')

      if status and status != issue.status:

          issue.status = status

+         if status.lower() != 'open':

+             issue.closed_at = datetime.datetime.utcnow()

          edit.append('status')

      if priority:

          try:

file modified
+4
@@ -565,6 +565,8 @@ 

      date_created = sa.Column(sa.DateTime, nullable=False,

                               default=datetime.datetime.utcnow)

  

+     closed_at = sa.Column(sa.DateTime, nullable=True)

+ 

      project = relation(

          'Project', foreign_keys=[project_id], remote_side=[Project.id],

          backref=backref(
@@ -632,6 +634,8 @@ 

              'content': self.content,

              'status': self.status,

              'date_created': self.date_created.strftime('%s'),

+             'closed_at': self.closed_at.strftime(

+                 '%s') if self.closed_at else None,

I bet you didn't run the tests :)

              'user': self.user.to_json(public=public),

              'private': self.private,

              'tags': self.tags_text,

@@ -86,6 +86,9 @@ 

          <tr>

              <th id="issue-title">Issue</th>

              <th class="open_date">Opened</th>

+             {% if status and status|lower != 'open' %}

+             <th class="close_date">Closed</th>

+             {% endif %}

              <th class="priority" data-sort="int">

                  Priority&nbsp;(<a href="{{ url_for('view_issues', username=username,

                  repo=repo.name, tags=tags, author=author, assignee=assignee,
@@ -96,11 +99,13 @@ 

                  repo=repo.name, tags=tags, assignee=assignee, priority=priority,

                  status=status) }}">reset</a>)

              </th>

+             {% if not status or status|lower == 'open' %}

              <th class="assigned">

                Assignee&nbsp;(<a href="{{ url_for('view_issues', username=username,

                  repo=repo.name, tags=tags, author=author, priority=priority,

                  status=status) }}">reset</a>)

              </th>

+             {% endif %}

          </tr>

      </thead>

      <tfoot>
@@ -140,6 +145,14 @@ 

                  <span title="{{issue.date_created.strftime('%Y-%m-%d %H:%M:%S')}}">{{

                          issue.date_created | humanize}}</span>

              </td>

+             {% if status and status|lower != 'open' %}

+             <td class="nowrap">

+                 {% if issue.closed_at != None %}

+                 <span title="{{issue.closed_at.strftime('%Y-%m-%d %H:%M:%S')}}">{{

+                         issue.closed_at | humanize}}</span>

+                 {% endif %}

+             </td>

+             {% endif %}

              <td class="td-priority nowrap" data-sort-value="{{

                issue.priority

                if issue.priority
@@ -155,6 +168,7 @@ 

                  </a>

                {% endif %}

              </td>

+             {% if not status or status|lower == 'open' %}

              <td class="nowrap">

                  <a href="{{ url_for('view_issues', username=username,

                      repo=repo.name, author=issue.user.user,
@@ -164,6 +178,7 @@ 

                      {{ issue.user.user }}

                  </a>

              </td>

+             {% endif %}

              <td class="nowrap">

                {% if issue.assignee %}

                <a href="{{ url_for('view_issues', username=username,

@@ -160,6 +160,7 @@ 

                    "comments": [],

                    "content": "This issue needs attention",

                    "date_created": "1431414800",

+                   "closed_at": None,

                    "depends": [],

                    "id": 1,

                    "priority": None,
@@ -212,6 +213,7 @@ 

                    "comments": [],

                    "content": "This issue needs attention",

                    "date_created": "1431414800",

+                   "closed_at": None,

                    "depends": [],

                    "id": 1,

                    "priority": None,
@@ -267,6 +269,7 @@ 

                    "comments": [],

                    "content": "This issue needs attention",

                    "date_created": "1431414800",

+                   "closed_at": None,

                    "depends": [],

                    "id": 1,

                    "priority": None,
@@ -308,6 +311,7 @@ 

                    "comments": [],

                    "content": "This issue needs attention",

                    "date_created": "1431414800",

+                   "closed_at": None,

                    "depends": [],

                    "id": 1,

                    "priority": None,
@@ -326,6 +330,7 @@ 

                    "comments": [],

                    "content": "We should work on this",

                    "date_created": "1431414800",

+                   "closed_at": None,

                    "depends": [],

                    "id": 2,

                    "priority": None,
@@ -401,6 +406,7 @@ 

                          "comments": [],

                          "content": "This issue needs attention",

                          "date_created": "1431414800",

+                         "closed_at": None,

                          "depends": [],

                          "id": 1,

                          "priority": None,
@@ -419,6 +425,7 @@ 

                          "comments": [],

                          "content": "We should work on this",

                          "date_created": "1431414800",

+                         "closed_at": None,

                          "depends": [],

                          "id": 2,

                          "priority": None,
@@ -476,6 +483,7 @@ 

                "comments": [],

                "content": "This issue needs attention",

                "date_created": "1431414800",

+               "closed_at": None,

                "depends": [],

                "id": 1,

                "priority": None,
@@ -570,6 +578,7 @@ 

                "comments": [],

                "content": "We should work on this",

                "date_created": "1431414800",

+               "closed_at": None,

                "depends": [],

                "id": 2,

                "priority": None,
@@ -597,6 +606,7 @@ 

                "comments": [],

                "content": "We should work on this",

                "date_created": "1431414800",

+               "closed_at": None,

                "depends": [],

                "id": 2,

                "priority": None,

file modified
+10 -3
@@ -470,10 +470,11 @@ 

  index 0000000..60f7480

  --- /dev/null

  +++ b/456

- @@ -0,0 +1,23 @@

+ @@ -0,0 +1,24 @@

  +{

  +    "assignee": null,

  +    "blocks": [],

+ +    "closed_at": null,

  +    "comments": [],

  +    "content": "We should work on this",

  +    "date_created": null,
@@ -515,6 +516,9 @@ 

              elif 'date_created' in row:

                  t = row.split(': ')[0]

                  row = '%s: null,' % t

+             elif 'closed_at' in row:

+                 t = row.split(': ')[0]

+                 row = '%s: null,' % t

              elif row.startswith('index 00'):

                  row = 'index 0000000..60f7480'

              elif row.startswith('+++ b/'):
@@ -550,10 +554,10 @@ 

  index 458821a..77674a8

  --- a/123

  +++ b/456

- @@ -1,7 +1,25 @@

-  {

+ @@ -2,7 +2,25 @@

       "assignee": null,

       "blocks": [],

+      "closed_at": null,

  -    "comments": [],

  +    "comments": [

  +        {
@@ -597,6 +601,9 @@ 

              elif 'date_created' in row:

                  t = row.split(': ')[0]

                  row = '%s: null,' % t

+             elif 'closed_at' in row:

+                 t = row.split(': ')[0]

+                 row = '%s: null,' % t

              elif row.startswith('index'):

                  row = 'index 458821a..77674a8'

              elif row.startswith('--- a/'):

I bet you didn't run the tests :)

For issues, I think we drop the assignee column

3 new commits added

  • modify tests after adding closed_at column in issues
  • remove assignee when showing the issues closed
  • modify alembic script since the notification in issues
7 years ago

Works for me (locally and in the tests), thanks! :)

Pull-Request has been merged by pingou

7 years ago