fix: i agree with nairobi

This commit is contained in:
zk
2026-05-17 19:38:29 +00:00
parent d84d04041f
commit dbf92f8e2e
5 changed files with 43 additions and 17 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ fix:
set -euo pipefail
just gen
bun run --elide-lines=0 --filter '*' lint-fix
bun run --elide-lines=0 --filter '*' lint-fix -- --quiet
.scripts/ts_autoinherit.js
just fmt
@@ -3,7 +3,7 @@
* with edit and withdraw capabilities.
*/
import type { UnsuccessfulAPIResponse } from "tachi-common";
import type { UnsuccessfulAPIResponse, UserDocument } from "tachi-common";
import useSetSubheader from "#components/layout/header/useSetSubheader";
import LoadingWrapper from "#components/util/LoadingWrapper";
@@ -51,6 +51,10 @@ export default function MyProposalsPage() {
return <Redirect to="/login" />;
}
return <MyProposalsPageInner user={user} />;
}
function MyProposalsPageInner({ user: _user }: { user: UserDocument }) {
const [data, setData] = useState<MyProposalsResponse | null>(null);
const [error, setError] = useState<UnsuccessfulAPIResponse | null>(null);
@@ -7,13 +7,7 @@
* updated compared to the base branch.
*/
import {
GITHUB_PAT_KEY,
SEEDS_DEFAULT_BRANCH,
SEEDS_GITHUB_HTML_URL,
SEEDS_REPO,
SEEDS_REPO_PATH,
} from "#lib/config";
import { GITHUB_PAT_KEY, SEEDS_GITHUB_HTML_URL, SEEDS_REPO } from "#lib/config";
import { getTransport } from "#lib/transport/transport";
import { useMemo } from "react";
import { useQuery } from "react-query";
@@ -42,12 +42,33 @@ describe("getDueFireTime", () => {
});
it("null last: daily monthly and yearly examples match a bounded forward reference", () => {
const specs: Array<{ schedule: string; now: string; maxSteps: number; daysBack: number }> = [
{ schedule: "5 0 * * *", now: "2026-05-17T18:45:30.000Z", maxSteps: 50, daysBack: 3 },
{ schedule: "0 0 * * *", now: "2026-05-17T18:45:30.000Z", maxSteps: 10, daysBack: 3 },
{ schedule: "0 0 1 * *", now: "2026-03-15T12:00:00.000Z", maxSteps: 40, daysBack: 60 },
{ schedule: "0 0 1 1 *", now: "2026-06-15T12:00:00.000Z", maxSteps: 10, daysBack: 400 },
];
const specs: Array<{ daysBack: number; maxSteps: number; now: string; schedule: string }> =
[
{
schedule: "5 0 * * *",
now: "2026-05-17T18:45:30.000Z",
maxSteps: 50,
daysBack: 3,
},
{
schedule: "0 0 * * *",
now: "2026-05-17T18:45:30.000Z",
maxSteps: 10,
daysBack: 3,
},
{
schedule: "0 0 1 * *",
now: "2026-03-15T12:00:00.000Z",
maxSteps: 40,
daysBack: 60,
},
{
schedule: "0 0 1 1 *",
now: "2026-06-15T12:00:00.000Z",
maxSteps: 10,
daysBack: 400,
},
];
for (const { schedule, now: nowIso, maxSteps, daysBack } of specs) {
const now = new Date(nowIso);
const start = new Date(now.getTime() - daysBack * 24 * 60 * 60 * 1000);
@@ -59,7 +80,12 @@ describe("getDueFireTime", () => {
it("non-null last: unchanged skip-missed semantics vs forward reference", () => {
const now = new Date("2026-05-17T18:45:30.000Z");
const last = new Date("2026-05-17T18:40:00.000Z");
const expected = dueFireTimeForwardFrom("* * * * *", new Date(last.getTime() + 1), now, 200);
const expected = dueFireTimeForwardFrom(
"* * * * *",
new Date(last.getTime() + 1),
now,
200,
);
expect(getDueFireTime("* * * * *", last, now)).toEqual(expected);
});
@@ -17,7 +17,9 @@ const CRON_ADVISORY_KEY2 = 0x63_72_6f_6e; // "cron"
* `next()` is still <= `now`, then advance with the same `next()` loop as the non-null path.
*/
export function getDueFireTime(schedule: string, last: Date | null, now: Date): Date | null {
const startAndFirstAfter = (start: Date): { it: ReturnType<typeof CronExpressionParser.parse>; first: Date } => {
const startAndFirstAfter = (
start: Date,
): { first: Date; it: ReturnType<typeof CronExpressionParser.parse> } => {
const it = CronExpressionParser.parse(schedule, { currentDate: start });
const first = it.next().toDate();
return { it, first };