Transform a raw GraphQL issue node into our clean structure.
(raw: dict)
| 120 | |
| 121 | |
| 122 | def transform_issue(raw: dict) -> dict: |
| 123 | """Transform a raw GraphQL issue node into our clean structure.""" |
| 124 | comments = [] |
| 125 | for c in raw["comments"]["nodes"]: |
| 126 | comments.append( |
| 127 | { |
| 128 | "author": c["author"]["login"] if c.get("author") else None, |
| 129 | "body": c["body"], |
| 130 | "created_at": c["createdAt"], |
| 131 | "updated_at": c["updatedAt"], |
| 132 | "reactions": transform_reactions(c.get("reactionGroups", [])), |
| 133 | } |
| 134 | ) |
| 135 | |
| 136 | timeline = [] |
| 137 | for t in raw["timelineItems"]["nodes"]: |
| 138 | transformed = transform_timeline_event(t) |
| 139 | if transformed: |
| 140 | timeline.append(transformed) |
| 141 | |
| 142 | return { |
| 143 | "number": raw["number"], |
| 144 | "title": raw["title"], |
| 145 | "body": raw["body"], |
| 146 | "state": raw["state"], |
| 147 | "author": raw["author"]["login"] if raw.get("author") else None, |
| 148 | "created_at": raw["createdAt"], |
| 149 | "updated_at": raw["updatedAt"], |
| 150 | "closed_at": raw["closedAt"], |
| 151 | "assignees": [a["login"] for a in raw["assignees"]["nodes"]], |
| 152 | "labels": [label["name"] for label in raw["labels"]["nodes"]], |
| 153 | "milestone": raw.get("milestone"), |
| 154 | "reactions": transform_reactions(raw.get("reactionGroups", [])), |
| 155 | "comment_count": raw["comments"]["totalCount"], |
| 156 | "comments": comments, |
| 157 | "timeline": timeline, |
| 158 | } |
| 159 | |
| 160 | |
| 161 | def fetch_all_issues(owner: str, repo: str, states: list[str] | None = None) -> list[dict]: |
no test coverage detected