(token: str)
| 28 | |
| 29 | |
| 30 | def _search_issues_graphql(token: str) -> list[dict[str, Any]]: |
| 31 | query = """ |
| 32 | query($cursor: String) { |
| 33 | issues( |
| 34 | filter: { description: { contains: "ci-regexp:" } } |
| 35 | first: 100 |
| 36 | after: $cursor |
| 37 | includeArchived: false |
| 38 | ) { |
| 39 | nodes { |
| 40 | identifier |
| 41 | title |
| 42 | description |
| 43 | url |
| 44 | state { |
| 45 | type |
| 46 | } |
| 47 | } |
| 48 | pageInfo { |
| 49 | hasNextPage |
| 50 | endCursor |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | """ |
| 55 | |
| 56 | all_issues: list[dict[str, Any]] = [] |
| 57 | cursor = None |
| 58 | |
| 59 | while True: |
| 60 | variables: dict[str, Any] = {} |
| 61 | if cursor: |
| 62 | variables["cursor"] = cursor |
| 63 | |
| 64 | response = requests.post( |
| 65 | "https://api.linear.app/graphql", |
| 66 | headers={ |
| 67 | "Authorization": token, |
| 68 | "Content-Type": "application/json", |
| 69 | }, |
| 70 | json={"query": query, "variables": variables}, |
| 71 | ) |
| 72 | |
| 73 | if response.status_code != 200: |
| 74 | raise ValueError( |
| 75 | f"Bad return code from Linear GraphQL: {response.status_code}, " |
| 76 | f"response={response.text[:500]}, " |
| 77 | f"has_token=True" |
| 78 | ) |
| 79 | |
| 80 | result = response.json() |
| 81 | if "errors" in result: |
| 82 | raise ValueError(f"Linear GraphQL errors: {result['errors']}") |
| 83 | |
| 84 | search_data = result["data"]["issues"] |
| 85 | for node in search_data["nodes"]: |
| 86 | if node is None: |
| 87 | continue |
no test coverage detected