#320 Return shorter list of builds in /api/1/events.
Closed 5 months ago by mikeb. Opened 5 months ago by jkaluza.
jkaluza/freshmaker models-requester  into  master

file modified
+13 -1

@@ -338,7 +338,7 @@ 

              "url": event_url,

              "dry_run": self.dry_run,

              "requester": self.requester,

-             "builds": [b.json() for b in self.builds],

+             "builds": [b.short_json() for b in self.builds],

          }

  

      def find_dependent_events(self):

@@ -531,6 +531,18 @@ 

              self.name, ArtifactType(self.type).name,

              ArtifactBuildState(self.state).name, self.event.message_id)

  

+     def short_json(self):

+         """

+         Returns the short JSON representation of the ArtifactBuild containing

+         just `id`, `name`, `build_id` and `state`.

+         """

+         return {

Could you also return original_nvr? We use this in Estuary, although I'm not sure how useful it is.

+             "id": self.id,

+             "state": self.state,

Ah, botas currently uses the state_name in the message. That could be converted to use just the state or you could also return the state_name here.

+             "build_id": self.build_id,

+             "name": self.name,

+         }

+ 

      def json(self):

          build_args = {}

          if self.build_args:

file modified
+5 -1

@@ -313,7 +313,11 @@ 

          self.assertEqual(data['message_id'], '2017-00000000-0000-0000-0000-000000000001')

          self.assertEqual(data['search_key'], 'RHSA-2018-101')

          self.assertEqual(data['event_type_id'], models.EVENT_TYPES[events.TestingEvent])

-         self.assertEqual(len(data['builds']), 3)

+         self.assertEqual(

+             data["builds"], [

+                 {'build_id': 1234, 'state': 0, 'id': 1, 'name': 'ed'},

+                 {'build_id': 1235, 'state': 0, 'id': 2, 'name': 'mksh'},

+                 {'build_id': 1236, 'state': 0, 'id': 3, 'name': 'bash'}])

  

      def test_query_events(self):

          resp = self.client.get('/api/1/events/')

no initial comment

This is for the "message too large for bash to swallow" issue?

Ship it! :european_post_office:

Could you also return original_nvr? We use this in Estuary, although I'm not sure how useful it is.

Hm... if you return the original_nvr you may want to also return the rebuilt_nvr too, for symmetry.

Ah, botas currently uses the state_name in the message. That could be converted to use just the state or you could also return the state_name here.

@jkaluza it looks like Estuary-Updater uses event_id as well in the build change messages.

After conversation with the team, we're closing this PR in favor of a different approach.

Pull-Request has been closed by mikeb

5 months ago