Skip to content

Commit d389936

Browse files
anderdcanderdc
andcommitted
feat(miners): unbound OPEN issues when since is omitted (#27)
When `since` is provided, behavior is unchanged: OPEN created on/after, CLOSED closed on/after — the scoring window. When `since` is omitted, the response now returns all currently-OPEN issues with no time bound and no CLOSED history. Callers asking for "current open-issue load" no longer need a synthetic epoch-since workaround that pulls a full all-time payload. Lets the validator's open-issue spam-multiplier count old still-open issues that fall outside the scoring lookback window — the gap called out in entrius/gittensor#929 / PR #930. Co-authored-by: anderdc <me@alexanderdc.com>
1 parent 2e08ec5 commit d389936

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎packages/das/src/api/miners/miners.controller.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,25 @@ export class MinersController {
3737
@ApiOperation({
3838
summary: "Issues authored by a miner",
3939
description:
40-
"Returns every issue the miner has authored since the given date, " +
41-
"including current labels with actor attribution and the PR number " +
42-
"(if any) that solved the issue.",
40+
"Returns issues the miner has authored, with current labels (actor " +
41+
"attribution) and any solving PR. When `since` is provided, returns " +
42+
"OPEN issues created on/after that date plus CLOSED issues closed " +
43+
"on/after that date (scoring window). When `since` is omitted, " +
44+
"returns all currently-OPEN issues with no time bound and no CLOSED " +
45+
"history (open-issue load counting).",
4346
})
4447
@ApiParam({ name: "githubId", description: "GitHub user ID (numeric)" })
4548
@ApiQuery({
4649
name: "since",
4750
required: false,
4851
description:
49-
"ISO timestamp. Defaults to 35 days ago (midnight UTC) if omitted.",
52+
"ISO timestamp. When omitted, the response contains all currently-" +
53+
"OPEN issues with no time bound and no CLOSED history.",
5054
})
5155
async getIssues(
5256
@Param("githubId") githubId: string,
5357
@Query("since") since?: string,
5458
): Promise<unknown> {
55-
return this.miners.getIssues(githubId, MinersService.resolveSince(since));
59+
return this.miners.getIssues(githubId, since ?? null);
5660
}
5761
}

‎packages/das/src/api/miners/miners.service.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ export class MinersService {
124124

125125
async getIssues(
126126
githubId: string,
127-
since: string,
127+
since: string | null,
128128
): Promise<{
129129
github_id: string;
130-
since: string;
130+
since: string | null;
131131
generated_at: string;
132132
issues: unknown[];
133133
}> {
@@ -208,7 +208,7 @@ export class MinersService {
208208
FROM issues i
209209
WHERE i.author_github_id = $1
210210
AND (
211-
(i.state = 'OPEN' AND i.created_at >= $2)
211+
(i.state = 'OPEN' AND ($2::timestamptz IS NULL OR i.created_at >= $2))
212212
OR (i.state = 'CLOSED' AND i.closed_at >= $2)
213213
)
214214
ORDER BY i.created_at DESC

0 commit comments

Comments
 (0)