[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][ftp-team/dak][deploy] 4 commits: feat(changelog): Add since_id filter to changelogs_v2



Title: GitLab

Joerg Jaspert pushed to branch deploy at Debian FTP Team / dak

Commits:

  • 6a5b71c7
    by Anton Gladky at 2025-09-18T20:50:27+00:00
    feat(changelog): Add since_id filter to changelogs_v2
    
    This commit introduces a new  parameter to the
     API endpoint. This allows clients to poll
    for changes based on the change ID, which is useful for
    incremental updates.  The parameter is validated to be a
    non-negative integer.
    
  • 8de93b8b
    by Anton Gladky at 2025-09-18T20:50:27+00:00
    Apply black formatter
    
  • 3d0037fd
    by Joerg Jaspert at 2025-09-18T20:51:37+00:00
    Merge branch 'add_since_id_to_changelogs' into 'master'
    
    v2 changelogs: add since_id cursor for incremental fetch
    
    See merge request ftp-team/dak!294
  • 5c529bf5
    by Joerg Jaspert at 2025-09-18T22:53:28+02:00
    Merge branch 'master' into deploy
    
    * master:
      Apply black formatter
      feat(changelog): Add since_id filter to changelogs_v2
    

1 changed file:

Changes:

  • dakweb/queries/changelog.py
    ... ... @@ -88,6 +88,7 @@ def changelogs_v2() -> str:
    88 88
           - since: (optional) ISO date/datetime (e.g. 2024-01-01 or 2024-01-01T12:00:00)
    
    89 89
           - till: (optional) ISO date/datetime upper bound (inclusive)
    
    90 90
           - source: (optional) exact source package name to restrict
    
    91
    +      - since_id: (optional) return only rows with id > since_id (id-based polling)
    
    91 92
           - limit: (optional) default 50, max 500
    
    92 93
           - offset: (optional) default 0
    
    93 94
     
    
    ... ... @@ -100,6 +101,7 @@ def changelogs_v2() -> str:
    100 101
         source_filter = bottle.request.query.get("source", "").strip()
    
    101 102
         since_param = bottle.request.query.get("since", "").strip()
    
    102 103
         till_param = bottle.request.query.get("till", "").strip()
    
    104
    +    since_id_str = bottle.request.query.get("since_id", "").strip()
    
    103 105
     
    
    104 106
         # Pagination params
    
    105 107
         try:
    
    ... ... @@ -134,6 +136,20 @@ def changelogs_v2() -> str:
    134 136
             bottle.response.status = 400
    
    135 137
             return json.dumps({"error": "Invalid till parameter (expected ISO date)"})
    
    136 138
     
    
    139
    +    # Validate id-based filter
    
    140
    +    since_id = None
    
    141
    +    if since_id_str:
    
    142
    +        try:
    
    143
    +            since_id = int(since_id_str)
    
    144
    +        except Exception:
    
    145
    +            bottle.response.status = 400
    
    146
    +            return json.dumps(
    
    147
    +                {"error": "Invalid since_id parameter (expected integer)"}
    
    148
    +            )
    
    149
    +        if since_id < 0:
    
    150
    +            bottle.response.status = 400
    
    151
    +            return json.dumps({"error": "since_id must be >= 0"})
    
    152
    +
    
    137 153
         s = DBConn().session()
    
    138 154
         try:
    
    139 155
             q = (
    
    ... ... @@ -165,6 +181,9 @@ def changelogs_v2() -> str:
    165 181
             if till_dt:
    
    166 182
                 # Inclusive upper bound
    
    167 183
                 q = q.filter(cast(DBChange.date, TIMESTAMP) <= till_dt)
    
    184
    +        if since_id is not None:
    
    185
    +            # Strictly greater than to avoid returning the last seen row again
    
    186
    +            q = q.filter(DBChange.change_id > since_id)
    
    168 187
     
    
    169 188
             q = q.order_by(DBChange.seen, DBChange.change_id)  # deterministic ordering
    
    170 189
     
    


  • Reply to: