From 98e002490411ee3a187f947fe0383d9fb1228e6f Mon Sep 17 00:00:00 2001
From: Jana Cupova <root@localhost>
Date: Apr 23 2023 07:30:24 +0000
Subject: Unify getSessionInfo output


Fixes: https://pagure.io/koji/issue/3793

---

diff --git a/kojihub/kojihub.py b/kojihub/kojihub.py
index 45d223d..b4476a8 100644
--- a/kojihub/kojihub.py
+++ b/kojihub/kojihub.py
@@ -10419,8 +10419,10 @@ class RootExports(object):
             ('master', 'master'),
             ('authtype', 'authtype'),
             ('callnum', 'callnum'),
-            ("date_part('epoch', start_time)", 'start_time'),
+            ('start_time', 'start_time'),
+            ("date_part('epoch', start_time)", 'start_ts'),
             ('update_time', 'update_time'),
+            ("date_part('epoch', update_time)", 'update_ts'),
             ('exclusive', 'exclusive'),
         ]
         columns, aliases = zip(*fields)
diff --git a/tests/test_hub/test_get_session_info.py b/tests/test_hub/test_get_session_info.py
index 9777421..d772326 100644
--- a/tests/test_hub/test_get_session_info.py
+++ b/tests/test_hub/test_get_session_info.py
@@ -41,10 +41,12 @@ class TestGetSessionInfo(DBQueryTestCase):
         self.assertEqual(query.clauses, ['expired is FALSE', 'user_id = %(user_id)i'])
         self.assertEqual(query.joins, None)
         self.assertEqual(query.columns, ['authtype', 'callnum', 'exclusive', 'expired', 'master',
-                                         "date_part('epoch', start_time)", 'update_time',
+                                         'start_time', "date_part('epoch', start_time)",
+                                         'update_time', "date_part('epoch', update_time)",
                                          'user_id'])
         self.assertEqual(query.aliases, ['authtype', 'callnum', 'exclusive', 'expired', 'master',
-                                         'start_time', 'update_time', 'user_id'])
+                                         'start_time', 'start_ts', 'update_time', 'update_ts',
+                                         'user_id'])
 
     def test_get_session_info_user_and_details(self):
         self.context.session.logged_in = True
@@ -56,10 +58,13 @@ class TestGetSessionInfo(DBQueryTestCase):
         self.assertEqual(query.clauses, ['expired is FALSE', 'user_id = %(user_id)i'])
         self.assertEqual(query.joins, None)
         self.assertEqual(query.columns, ['authtype', 'callnum', 'exclusive', 'expired', 'hostip',
-                                         'id', 'master', "date_part('epoch', start_time)",
-                                         'update_time', 'user_id'])
+                                         'id', 'master', 'start_time',
+                                         "date_part('epoch', start_time)",
+                                         'update_time', "date_part('epoch', update_time)",
+                                         'user_id'])
         self.assertEqual(query.aliases, ['authtype', 'callnum', 'exclusive', 'expired', 'hostip',
-                                         'id', 'master', 'start_time', 'update_time', 'user_id'])
+                                         'id', 'master', 'start_time', 'start_ts', 'update_time',
+                                         'update_ts', 'user_id'])
 
     def test_get_session_info_user(self):
         self.context.session.logged_in = True
@@ -71,10 +76,12 @@ class TestGetSessionInfo(DBQueryTestCase):
         self.assertEqual(query.clauses, ['expired is FALSE', 'user_id = %(user_id)i'])
         self.assertEqual(query.joins, None)
         self.assertEqual(query.columns, ['authtype', 'callnum', 'exclusive', 'expired', 'master',
-                                         "date_part('epoch', start_time)", 'update_time',
+                                         'start_time', "date_part('epoch', start_time)",
+                                         'update_time', "date_part('epoch', update_time)",
                                          'user_id'])
         self.assertEqual(query.aliases, ['authtype', 'callnum', 'exclusive', 'expired', 'master',
-                                         'start_time', 'update_time', 'user_id'])
+                                         'start_time', 'start_ts', 'update_time', 'update_ts',
+                                         'user_id'])
 
     def test_get_session_info_details(self):
         self.context.session.logged_in = True
@@ -87,7 +94,9 @@ class TestGetSessionInfo(DBQueryTestCase):
         self.assertEqual(query.clauses, ['expired is FALSE', 'id = %(id)i'])
         self.assertEqual(query.joins, None)
         self.assertEqual(query.columns, ['authtype', 'callnum', 'exclusive', 'expired', 'hostip',
-                                         'id', 'master', "date_part('epoch', start_time)",
-                                         'update_time', 'user_id'])
+                                         'id', 'master', 'start_time',
+                                         "date_part('epoch', start_time)", 'update_time',
+                                         "date_part('epoch', update_time)", 'user_id'])
         self.assertEqual(query.aliases, ['authtype', 'callnum', 'exclusive', 'expired', 'hostip',
-                                         'id', 'master', 'start_time', 'update_time', 'user_id'])
+                                         'id', 'master', 'start_time', 'start_ts', 'update_time',
+                                         'update_ts', 'user_id'])

