Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions backend/src/github_pm/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import defaultdict
from datetime import datetime
import re
import time
from typing import Annotated, Any, AsyncGenerator

Expand All @@ -13,6 +14,10 @@
api_router = APIRouter()


# We sort "semver" style milestones first, then others alphabetically
VERSION_MATCH = re.compile(r"^v\d+\.\d+\.\d+$")


class Connector:

def __init__(self, github_token: str):
Expand Down Expand Up @@ -255,6 +260,16 @@ async def get_milestones(gitctx: Annotated[Connector, Depends(connection)]):
f"/repos/{context.github_repo}/milestones",
headers={"Accept": "application/vnd.github.html+json"},
)
versions = []
others = []
for m in milestones:
if VERSION_MATCH.match(m["title"]):
versions.append(m)
else:
others.append(m)
milestones = sorted(versions, key=lambda x: x["title"]) + sorted(
others, key=lambda x: x["title"]
)
milestones.append(
{
"title": "none",
Expand Down