Skip to content

Commit

Permalink
Expose timeline date for all artifacts in a story in a consistent format
Browse files Browse the repository at this point in the history
  • Loading branch information
sarah256 committed Jun 24, 2019
1 parent f46fcf5 commit 2af8bd7
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 40 deletions.
2 changes: 2 additions & 0 deletions estuary/api/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def _get_partial_story(results, reverse=False):
rv['meta']['story_type'] = story_manager.__class__.__name__[:-12].lower()
rv['data'][0]['resource_type'] = item.__label__
rv['data'][0]['display_name'] = item.display_name
rv['data'][0]['timeline_timestamp'] = item.timeline_timestamp
return jsonify(rv)

return jsonify(story_manager.format_story_results(results, item))
Expand Down Expand Up @@ -232,6 +233,7 @@ def _get_partial_stories(results, reverse=False):
rv['meta']['story_type'] = story_manager.__class__.__name__[:-12].lower()
rv['data'][0]['resource_type'] = item.__label__
rv['data'][0]['display_name'] = item.display_name
rv['data'][0]['timeline_timestamp'] = item.timeline_timestamp
all_results.append(rv)

return jsonify(all_results)
Expand Down
5 changes: 5 additions & 0 deletions estuary/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def display_name(self):
"""Get intuitive (human readable) display name for the node."""
raise NotImplementedError('The display_name method is not defined')

@property
def timeline_timestamp(self):
"""Get the DateTime property used for the Estuary timeline."""
raise NotImplementedError('The timeline_timestamp method is not defined')

@property
def serialized(self):
"""
Expand Down
5 changes: 5 additions & 0 deletions estuary/models/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def display_name(self):
"""Get intuitive (human readable) display name for the node."""
return 'RHBZ#{0}'.format(self.id_)

@property
def timeline_timestamp(self):
"""Get the DateTime property used for the Estuary timeline."""
return self.creation_time.strftime("%Y-%m-%dT%H:%M:%SZ")

@classmethod
def find_or_none(cls, identifier):
"""
Expand Down
5 changes: 5 additions & 0 deletions estuary/models/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ class DistGitCommit(EstuaryStructuredNode):
def display_name(self):
"""Get intuitive (human readable) display name for the node."""
return 'commit #{0}'.format(self.hash_[:7])

@property
def timeline_timestamp(self):
"""Get the DateTime property used for the Estuary timeline."""
return self.commit_date.strftime("%Y-%m-%dT%H:%M:%SZ")
5 changes: 5 additions & 0 deletions estuary/models/errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def display_name(self):
"""Get intuitive (human readable) display name for the node."""
return self.advisory_name

@property
def timeline_timestamp(self):
"""Get the DateTime property used for the Estuary timeline."""
return self.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")

@classmethod
def find_or_none(cls, identifier):
"""
Expand Down
5 changes: 5 additions & 0 deletions estuary/models/freshmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def display_name(self):
"""Get intuitive (human readable) display name for the node."""
return 'Freshmaker event {0}'.format(self.id_)

@property
def timeline_timestamp(self):
"""Get the DateTime property used for the Estuary timeline."""
return self.time_created.strftime("%Y-%m-%dT%H:%M:%SZ")


class FreshmakerBuild(EstuaryStructuredNode):
"""Definition of a Freshmaker build in Neo4j."""
Expand Down
5 changes: 5 additions & 0 deletions estuary/models/koji.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def display_name(self):
"""Get intuitive (human readable) display name for the node."""
return '{0}-{1}-{2}'.format(self.name, self.version, self.release)

@property
def timeline_timestamp(self):
"""Get the DateTime property used for the Estuary timeline."""
return self.creation_time.strftime("%Y-%m-%dT%H:%M:%SZ")

@classmethod
def find_or_none(cls, identifier):
"""
Expand Down
1 change: 1 addition & 0 deletions estuary/utils/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def format_story_results(self, results, requested_item):
serialized_node = node.serialized
serialized_node['resource_type'] = node.__label__
serialized_node['display_name'] = node.display_name
serialized_node['timeline_timestamp'] = node.timeline_timestamp
data.append(serialized_node)
return {
'data': data,
Expand Down
64 changes: 48 additions & 16 deletions tests/api/test_all_stories.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'short_description':'Some description',
'status':'VERIFIED',
'target_milestone':'rc',
'timeline_timestamp': '2017-04-02T19:39:06Z',
'votes':0
},
{
Expand All @@ -60,7 +61,8 @@
'display_name': 'commit #8a63adb',
'hash': '8a63adb248ba633e200067e1ad6dc61931727bad',
'log_message': 'Related: #12345 - fix xyz',
'resource_type': 'DistGitCommit'
'resource_type': 'DistGitCommit',
'timeline_timestamp': '2017-04-26T11:44:38Z'
},
{
'completion_time': '2017-04-02T19:39:06Z',
Expand All @@ -74,6 +76,7 @@
'resource_type': 'KojiBuild',
'start_time': '2017-04-02T19:39:06Z',
'state': 1,
'timeline_timestamp': '2017-04-02T19:39:06Z',
'version': '1.7.4'
},
{
Expand All @@ -95,7 +98,8 @@
'state':'DROPPED_NO_SHIP',
'status_time': '2018-03-14T07:53:25Z',
'synopsis':'This is a synopsis of a test advisory.',
'update_date': '2018-03-14T07:53:25Z'
'update_date': '2018-03-14T07:53:25Z',
'timeline_timestamp': '2018-03-14T05:53:25Z'
}
],
'meta':{
Expand Down Expand Up @@ -142,6 +146,7 @@
'short_description':'Some description',
'status':'VERIFIED',
'target_milestone':'rc',
'timeline_timestamp': '2017-04-02T19:39:06Z',
'votes':0
},
{
Expand All @@ -150,7 +155,8 @@
'display_name': 'commit #8a63adb',
'hash': '8a63adb248ba633e200067e1ad6dc61931727bad',
'log_message': 'Related: #12345 - fix xyz',
'resource_type': 'DistGitCommit'
'resource_type': 'DistGitCommit',
'timeline_timestamp': '2017-04-26T11:44:38Z'
},
{
'completion_time': '2017-04-02T19:39:06Z',
Expand All @@ -164,6 +170,7 @@
'resource_type': 'KojiBuild',
'start_time': '2017-04-02T19:39:06Z',
'state': 1,
'timeline_timestamp': '2017-04-02T19:39:06Z',
'version': '1.7.4'
},
{
Expand All @@ -185,7 +192,8 @@
'state':'SHIPPED_LIVE',
'status_time': '2017-08-01T15:43:51Z',
'synopsis':'cifs-utils bug fix update',
'update_date': '2017-08-01T07:16:00Z'
'update_date': '2017-08-01T07:16:00Z',
'timeline_timestamp': '2017-04-03T14:47:23Z'
},
{
'display_name': 'Freshmaker event 1180',
Expand All @@ -197,7 +205,8 @@
'state_name': 'COMPLETE',
'state_reason': 'All container images have been rebuilt.',
'time_created': '2019-08-21T13:42:20Z',
'time_done': '2099-08-21T13:42:20Z'
'time_done': '2099-08-21T13:42:20Z',
'timeline_timestamp': '2019-08-21T13:42:20Z'
},
{
'completion_time': '2018-04-02T19:39:06Z',
Expand All @@ -212,6 +221,7 @@
'resource_type': 'ContainerKojiBuild',
'start_time': '2018-04-02T19:39:06Z',
'state': 2,
'timeline_timestamp': '2018-04-02T19:39:06Z',
'version': '1.7.5'
}
],
Expand Down Expand Up @@ -241,6 +251,7 @@
'short_description': 'Some description',
'status': 'VERIFIED',
'target_milestone': 'rc',
'timeline_timestamp': '2017-04-02T19:39:06Z',
'votes': 0
},
{
Expand All @@ -249,7 +260,8 @@
'display_name': 'commit #8a63adb',
'hash': '8a63adb248ba633e200067e1ad6dc61931727bad',
'log_message': 'Related: #12345 - fix xyz',
'resource_type': 'DistGitCommit'
'resource_type': 'DistGitCommit',
'timeline_timestamp': '2017-04-26T11:44:38Z',
},
{
'advisories': [
Expand Down Expand Up @@ -316,6 +328,7 @@
'tags':[
],
'timeline_timestamp': '2017-04-02T19:39:06Z',
'version':'1.7.4'
},
{
Expand All @@ -337,7 +350,8 @@
'state':'DROPPED_NO_SHIP',
'status_time': '2018-03-14T07:53:25Z',
'synopsis':'This is a synopsis of a test advisory.',
'update_date': '2018-03-14T07:53:25Z'
'update_date': '2018-03-14T07:53:25Z',
'timeline_timestamp': '2018-03-14T05:53:25Z'
}
],
'meta':{
Expand All @@ -364,6 +378,7 @@
'short_description': 'some description',
'status': 'CLOSED',
'target_milestone': 'rc',
'timeline_timestamp': '2017-04-01T17:41:04Z',
'votes': 0
},
{
Expand All @@ -372,7 +387,8 @@
'display_name': 'commit #f4dfc64',
'hash': 'f4dfc64c10a90492303e4f14ad3549a1a2b13575',
'log_message': 'Repo creation',
'resource_type': 'DistGitCommit'
'resource_type': 'DistGitCommit',
'timeline_timestamp': '2018-03-14T05:52:19Z'
},
{
'advisories': [
Expand Down Expand Up @@ -439,6 +455,7 @@
'tags':[
],
'timeline_timestamp': '2017-04-02T19:39:06Z',
'version':'1.7.4'
},
{
Expand All @@ -460,7 +477,8 @@
'state':'DROPPED_NO_SHIP',
'status_time': '2018-03-14T07:53:25Z',
'synopsis':'This is a synopsis of a test advisory.',
'update_date': '2018-03-14T07:53:25Z'
'update_date': '2018-03-14T07:53:25Z',
'timeline_timestamp': '2018-03-14T05:53:25Z'
}
],
'meta':{
Expand All @@ -487,6 +505,7 @@
'short_description': 'Some description',
'status': 'VERIFIED',
'target_milestone': 'rc',
'timeline_timestamp': '2017-04-02T19:39:06Z',
'votes': 0
},
{
Expand All @@ -495,7 +514,8 @@
'display_name': 'commit #8a63adb',
'hash': '8a63adb248ba633e200067e1ad6dc61931727bad',
'log_message': 'Related: #12345 - fix xyz',
'resource_type': 'DistGitCommit'
'resource_type': 'DistGitCommit',
'timeline_timestamp': '2017-04-26T11:44:38Z'
},
{
'advisories': [
Expand Down Expand Up @@ -562,6 +582,7 @@
'tags':[
],
'timeline_timestamp': '2017-04-02T19:39:06Z',
'version':'1.7.4'
},
{
Expand All @@ -583,7 +604,8 @@
'state':'SHIPPED_LIVE',
'status_time': '2017-08-01T15:43:51Z',
'synopsis':'cifs-utils bug fix update',
'update_date': '2017-08-01T07:16:00Z'
'update_date': '2017-08-01T07:16:00Z',
'timeline_timestamp': '2017-04-03T14:47:23Z'
},
{
'display_name': 'Freshmaker event 1180',
Expand All @@ -595,7 +617,8 @@
'state_name': 'COMPLETE',
'state_reason': 'All container images have been rebuilt.',
'time_created': '2019-08-21T13:42:20Z',
'time_done': '2099-08-21T13:42:20Z'
'time_done': '2099-08-21T13:42:20Z',
'timeline_timestamp': '2019-08-21T13:42:20Z'
},
{
'completion_time': '2018-04-02T19:39:06Z',
Expand All @@ -610,6 +633,7 @@
'resource_type': 'ContainerKojiBuild',
'start_time': '2018-04-02T19:39:06Z',
'state': 2,
'timeline_timestamp': '2018-04-02T19:39:06Z',
'version': '1.7.5'
}
],
Expand Down Expand Up @@ -637,6 +661,7 @@
'short_description': 'some description',
'status': 'CLOSED',
'target_milestone': 'rc',
'timeline_timestamp': '2017-04-01T17:41:04Z',
'votes': 0
},
{
Expand All @@ -645,7 +670,8 @@
'display_name': 'commit #f4dfc64',
'hash': 'f4dfc64c10a90492303e4f14ad3549a1a2b13575',
'log_message': 'Repo creation',
'resource_type': 'DistGitCommit'
'resource_type': 'DistGitCommit',
'timeline_timestamp': '2018-03-14T05:52:19Z'
},
{
'advisories': [
Expand Down Expand Up @@ -712,6 +738,7 @@
'tags':[
],
'timeline_timestamp': '2017-04-02T19:39:06Z',
'version':'1.7.4'
},
{
Expand All @@ -733,7 +760,8 @@
'state':'SHIPPED_LIVE',
'status_time': '2017-08-01T15:43:51Z',
'synopsis':'cifs-utils bug fix update',
'update_date': '2017-08-01T07:16:00Z'
'update_date': '2017-08-01T07:16:00Z',
'timeline_timestamp': '2017-04-03T14:47:23Z'
},
{
'display_name': 'Freshmaker event 1180',
Expand All @@ -745,7 +773,8 @@
'state_name': 'COMPLETE',
'state_reason': 'All container images have been rebuilt.',
'time_created': '2019-08-21T13:42:20Z',
'time_done': '2099-08-21T13:42:20Z'
'time_done': '2099-08-21T13:42:20Z',
'timeline_timestamp': '2019-08-21T13:42:20Z'
},
{
'completion_time': '2018-04-02T19:39:06Z',
Expand All @@ -760,6 +789,7 @@
'resource_type': 'ContainerKojiBuild',
'start_time': '2018-04-02T19:39:06Z',
'state': 2,
'timeline_timestamp': '2018-04-02T19:39:06Z',
'version': '1.7.5'
}
],
Expand Down Expand Up @@ -973,6 +1003,7 @@ def test_get_stories_fallback(client):
'start_time': '2017-04-02T19:39:06Z',
'state': 1,
'tags': [],
'timeline_timestamp': '2017-04-02T19:39:06Z',
'version': '1.7.4'
},
{
Expand All @@ -992,7 +1023,8 @@ def test_get_stories_fallback(client):
'state': 'SHIPPED_LIVE',
'status_time': '2017-08-01T15:43:51Z',
'synopsis': 'cifs-utils bug fix update',
'update_date': '2017-08-01T07:16:00Z'
'update_date': '2017-08-01T07:16:00Z',
'timeline_timestamp': '2017-04-03T14:47:23Z'
}
],
'meta': {
Expand Down
1 change: 1 addition & 0 deletions tests/api/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def test_get_story_auth(mock_oidc, employee_type):
'start_time': '2017-04-02T19:39:06Z',
'state': 1,
'tags': [],
'timeline_timestamp': '2017-04-02T19:39:06Z',
'version': '1.7.4'
}
],
Expand Down

0 comments on commit 2af8bd7

Please sign in to comment.