From b3132a78a5e74d0c05fc7eba163bf94fa18c2b4e Mon Sep 17 00:00:00 2001
From: Clement Verna <cverna@tutanota.com>
Date: Oct 19 2016 19:41:51 +0000
Subject: [PATCH 1/3] Add support for close status


---

diff --git a/pagure_importer/utils/importer_trac.py b/pagure_importer/utils/importer_trac.py
index dce5a13..b922593 100644
--- a/pagure_importer/utils/importer_trac.py
+++ b/pagure_importer/utils/importer_trac.py
@@ -103,7 +103,7 @@ class TracImporter():
         if pagure_issue_content == '':
             pagure_issue_content = '#No Description Provided'
 
-        pagure_issue_status = self.get_ticket_status(trac_ticket)
+        issue_status, close_status = self.get_ticket_status(trac_ticket)
 
         pagure_issue_created_at = self.to_timestamp(
             trac_ticket_info[1]['__jsonclass__'][1])
@@ -147,7 +147,8 @@ class TracImporter():
             id=ticket_id,
             title=pagure_issue_title,
             content=pagure_issue_content,
-            status=pagure_issue_status,
+            status=issue_status,
+            close_status=close_status,
             date_created=pagure_issue_created_at,
             user=pagure_issue_user.to_json(),
             private=pagure_issue_is_private,
@@ -162,10 +163,14 @@ class TracImporter():
         ''' Returns the corresponding status of ticket on pagure '''
 
         if trac_ticket['status'] != 'closed':
-            ticket_status = 'Open'
+            return ('Open', '')
+        elif trac_ticket['resolution'] in ['invalid', 'wontfix',
+                                           'worksforme', 'duplicate']:
+            return ('Closed', 'Invalid')
+        elif trac_ticket['resolution'] == 'insufficient_info':
+            return ('Closed', 'Insufficient data')
         else:
-            ticket_status = 'Closed'
-        return ticket_status
+            return ('Closed', 'Fixed')
 
     def get_comment_user(self, comment):
         ''' Returns the user who commented on the ticket '''
diff --git a/pagure_importer/utils/models.py b/pagure_importer/utils/models.py
index c4c4e4e..526b871 100644
--- a/pagure_importer/utils/models.py
+++ b/pagure_importer/utils/models.py
@@ -7,13 +7,14 @@ class Issue():
 
     def __init__(
             self, id, title, content,
-            status, date_created, user, private, attachment, tags,
-            depends, blocks, assignee, comments=None, milestone=None):
+            status, close_status, date_created, user, private, attachment,
+            tags, depends, blocks, assignee, comments=None, milestone=None):
 
         self.id = id
         self.title = title
         self.content = content
         self.status = status
+        self.close_status = close_status
         self.date_created = date_created
         self.user = user
         self.private = private
@@ -35,6 +36,7 @@ class Issue():
             'title': self.title,
             'content': self.content,
             'status': self.status,
+            'close_status': self.close_status,
             'date_created': self.date_created,
             'user': self.user,
             'private': self.private,

From c5a867b2f8cf7e05087ea3cf371b3d70d0f21f6f Mon Sep 17 00:00:00 2001
From: Clement Verna <cverna@tutanota.com>
Date: Oct 19 2016 21:09:26 +0000
Subject: [PATCH 2/3] Default close status to fixed for github importer


---

diff --git a/pagure_importer/utils/models.py b/pagure_importer/utils/models.py
index 526b871..78bcf60 100644
--- a/pagure_importer/utils/models.py
+++ b/pagure_importer/utils/models.py
@@ -7,8 +7,9 @@ class Issue():
 
     def __init__(
             self, id, title, content,
-            status, close_status, date_created, user, private, attachment,
-            tags, depends, blocks, assignee, comments=None, milestone=None):
+            status, date_created, user, private, attachment, tags,
+            depends, blocks, assignee, comments=None, milestone=None,
+            close_status='Fixed'):
 
         self.id = id
         self.title = title

From 9ddabdd41cc9bde59c9af3faeb3e4f95fab8e241 Mon Sep 17 00:00:00 2001
From: Clement Verna <cverna@tutanota.com>
Date: Oct 20 2016 18:24:03 +0000
Subject: [PATCH 3/3] Make close_status generic across importer


---

diff --git a/pagure_importer/utils/importer_github.py b/pagure_importer/utils/importer_github.py
index fb7e4f2..e53c1f4 100644
--- a/pagure_importer/utils/importer_github.py
+++ b/pagure_importer/utils/importer_github.py
@@ -48,8 +48,10 @@ class GithubImporter():
             # Some details of a issue
             if github_issue.state != 'closed':
                 pagure_issue_status = 'Open'
+                close_status=''
             else:
                 pagure_issue_status = 'Closed'
+                close_status = 'Fixed'
 
             pagure_issue_created_at = github_issue.created_at.strftime('%s')
             # Not sure how to deal with this atm
@@ -79,6 +81,7 @@ class GithubImporter():
                     title=pagure_issue_title,
                     content=pagure_issue_content,
                     status=pagure_issue_status,
+                    close_status=close_status,
                     date_created=pagure_issue_created_at,
                     user=pagure_issue_user.to_json(),
                     private=pagure_issue_is_private,
diff --git a/pagure_importer/utils/models.py b/pagure_importer/utils/models.py
index 78bcf60..8b0dfbf 100644
--- a/pagure_importer/utils/models.py
+++ b/pagure_importer/utils/models.py
@@ -8,8 +8,8 @@ class Issue():
     def __init__(
             self, id, title, content,
             status, date_created, user, private, attachment, tags,
-            depends, blocks, assignee, comments=None, milestone=None,
-            close_status='Fixed'):
+            depends, blocks, assignee, close_status, comments=None,
+            milestone=None):
 
         self.id = id
         self.title = title

