def json(self): build_args = {} if self.build_args: build_args = json.loads(self.build_args) build_url = get_url_for('build', id=self.id) db.session.add(self) return { "id": self.id, "name": self.name, "original_nvr": self.original_nvr, "rebuilt_nvr": self.rebuilt_nvr, "type": self.type, "type_name": ArtifactType(self.type).name, "state": self.state, "state_name": ArtifactBuildState(self.state).name, "state_reason": self.state_reason, "dep_on": self.dep_on.name if self.dep_on else None, "dep_on_id": self.dep_on.id if self.dep_on else None, "time_submitted": _utc_datetime_to_iso(self.time_submitted), "time_completed": _utc_datetime_to_iso(self.time_completed), "event_id": self.event_id, "build_id": self.build_id, "url": build_url, "build_args": build_args, "odcs_composes": [rel.compose.odcs_compose_id for rel in self.composes], "rebuild_reason": RebuildReason(self.rebuild_reason or 0).name.lower() }
def _common_json(self): event_url = get_url_for('event', id=self.id) db.session.add(self) return { "id": self.id, "message_id": self.message_id, "search_key": self.search_key, "event_type_id": self.event_type_id, "state": self.state, "state_name": EventState(self.state).name, "state_reason": self.state_reason, "time_created": _utc_datetime_to_iso(self.time_created), "time_done": _utc_datetime_to_iso(self.time_done), "url": event_url, "dry_run": self.dry_run, "requester": self.requester, "requested_rebuilds": (self.requested_rebuilds.split(" ") if self.requested_rebuilds else []), "requester_metadata": self.requester_metadata_json, "depends_on_events": [event.id for event in self.event_dependencies], "depending_events": [event.id for event in self.depending_events], }