|  | 
| 15 | 15 |     get_per_issue_metrics(issues: Union[List[dict], List[github3.issues.Issue]], | 
| 16 | 16 |         discussions: bool = False) -> tuple[List, int, int]: | 
| 17 | 17 |         Calculate the metrics for each issue in a list of GitHub issues. | 
| 18 |  | -    get_repo_owner_and_name(search_query: str) -> tuple[Union[str, None], Union[str, None]]: | 
| 19 |  | -        Get the repository owner and name from the search query. | 
| 20 |  | -    get_organization(search_query: str) -> Union[str, None]: Get the organization | 
| 21 |  | -        from the search query. | 
|  | 18 | +    get_owner(search_query: str) -> Union[str, None]]: | 
|  | 19 | +        Get the owner from the search query. | 
| 22 | 20 |     main(): Run the issue-metrics script. | 
| 23 | 21 | """ | 
| 24 | 22 | 
 | 
| @@ -191,46 +189,27 @@ def get_per_issue_metrics( | 
| 191 | 189 |     return issues_with_metrics, num_issues_open, num_issues_closed | 
| 192 | 190 | 
 | 
| 193 | 191 | 
 | 
| 194 |  | -def get_repo_owner_and_name( | 
|  | 192 | +def get_owner( | 
| 195 | 193 |     search_query: str, | 
| 196 |  | -) -> tuple[Union[str, None], Union[str, None]]: | 
| 197 |  | -    """Get the repository owner and name from the search query. | 
|  | 194 | +) -> Union[str, None]: | 
|  | 195 | +    """Get the owner from the search query. | 
| 198 | 196 | 
 | 
| 199 | 197 |     Args: | 
| 200 | 198 |         search_query (str): The search query used to search for issues. | 
| 201 | 199 | 
 | 
| 202 | 200 |     Returns: | 
| 203 |  | -        tuple[Union[str, None], Union[str, None]]: A tuple containing the repository owner and name. | 
|  | 201 | +        Union[str, None]: The owner. | 
| 204 | 202 | 
 | 
| 205 | 203 |     """ | 
| 206 | 204 |     search_query_split = search_query.split(" ") | 
| 207 |  | -    repo_owner, repo_name = None, None | 
|  | 205 | +    owner = None | 
| 208 | 206 |     for item in search_query_split: | 
| 209 | 207 |         if "repo:" in item and "/" in item: | 
| 210 |  | -            repo_owner = item.split(":")[1].split("/")[0] | 
| 211 |  | -            repo_name = item.split(":")[1].split("/")[1] | 
|  | 208 | +            owner = item.split(":")[1].split("/")[0] | 
|  | 209 | +        if "org:" in item or "owner:" in item or "user:" in item: | 
|  | 210 | +            owner = item.split(":")[1] | 
| 212 | 211 | 
 | 
| 213 |  | -    return repo_owner, repo_name | 
| 214 |  | - | 
| 215 |  | - | 
| 216 |  | -def get_organization(search_query: str) -> Union[str, None]: | 
| 217 |  | -    """Get the organization from the search query. | 
| 218 |  | -
 | 
| 219 |  | -    Args: | 
| 220 |  | -        search_query (str): The search query used to search for issues. | 
| 221 |  | -
 | 
| 222 |  | -    Returns: | 
| 223 |  | -        Union[str, None]: The organization from the search query. | 
| 224 |  | -
 | 
| 225 |  | -    """ | 
| 226 |  | -    # Get the organization from the search query | 
| 227 |  | -    search_query_split = search_query.split(" ") | 
| 228 |  | -    organization = None | 
| 229 |  | -    for item in search_query_split: | 
| 230 |  | -        if "org:" in item: | 
| 231 |  | -            organization = item.split(":")[1] | 
| 232 |  | - | 
| 233 |  | -    return organization | 
|  | 212 | +    return owner | 
| 234 | 213 | 
 | 
| 235 | 214 | 
 | 
| 236 | 215 | def main(): | 
| @@ -261,13 +240,13 @@ def main(): | 
| 261 | 240 |     token = env_vars[1] | 
| 262 | 241 | 
 | 
| 263 | 242 |     # Get the repository owner and name from the search query | 
| 264 |  | -    owner, repo_name = get_repo_owner_and_name(search_query) | 
| 265 |  | -    organization = get_organization(search_query) | 
|  | 243 | +    owner = get_owner(search_query) | 
| 266 | 244 | 
 | 
| 267 |  | -    if (owner is None or repo_name is None) and organization is None: | 
|  | 245 | +    if owner is None: | 
| 268 | 246 |         raise ValueError( | 
| 269 | 247 |             "The search query must include a repository owner and name \ | 
| 270 |  | -            (ie. repo:owner/repo) or an organization (ie. org:organization)" | 
|  | 248 | +            (ie. repo:owner/repo), an organization (ie. org:organization), \ | 
|  | 249 | +            a user (ie. user:login) or an owner (ie. owner:user-or-organization)" | 
| 271 | 250 |         ) | 
| 272 | 251 | 
 | 
| 273 | 252 |     # Determine if there are label to measure | 
|  | 
0 commit comments