Skip to content

refactor(jira): share todos' Jira client for the time service - #147

Merged
Bakhomious merged 1 commit into
mainfrom
step/shared-jira
Oct 29, 2026
Merged

Bakhomious merged 1 commit into
mainfrom
step/shared-jira

Conversation

@Bakhomious

Copy link
Copy Markdown
Contributor

Brief

Goal. todos' Jira client moves to the root internal/jira, so that the time service can read worklogs with the same client, settings and token (decision 103). It's the first of time-tracking's eleven steps (plan §8.2, decision 180). Nothing changes in behaviour.

Scope.

  • services/todos/internal/jira's client (client.go, fetch.go, ticket.go) and its tests move to internal/jira, unchanged but for the package doc.
  • jira.FromEnv in internal/jira/env.go: todos' jiraClient, moved verbatim. It reads BAKHYARD_JIRA_SITE, BAKHYARD_JIRA_API and BAKHYARD_JIRA_EMAIL and the jira-token secret, and gives no client when no setting is set. Its tests move with it.
  • todos' poller of my tickets (poll.go, with Poller, NewPoller, Found and Finder) moves to services/todos/internal/tickets, since it's todos' own; internal/jira keeps only what talks to Jira.
  • todos' attention and api packages and main follow the moves. Their parameters and fields named tickets become poller, so they don't shadow the new package.
  • Docs: plan §0, §8.2 (time-tracking's eleven steps), §0's ideas (a holidays setting), and decision 180, which amends decision 135.

Out of scope. Worklogs, the time service and anything else of time-tracking's later steps; any change to how todos polls Jira or what it answers.

Acceptance criteria.

  1. internal/jira holds the client and FromEnv; services/todos/internal/jira is gone.
  2. services/todos/internal/tickets holds the poller; todos builds and serves as before.
  3. Every test still runs: the same 112 test functions, todos' four TestJiraClient* now internal/jira's TestFromEnv*.
  4. The moved code is unchanged but for package names, imports and renames.
  5. mise run check passes.

What changed

  • Moved (git sees renames): internal/jira/{client,fetch,ticket}.go and {client,fail,fake,fetch,fetchfail}_test.go; services/todos/internal/tickets/{poll.go,poll_test.go,done_test.go,finder_test.go}.
  • New: internal/jira/env.go (FromEnv) and env_test.go (the four tests from services/todos/jira_test.go, with their helpers).
  • services/todos/jira.go keeps only poll; main.go calls jira.FromEnv.
  • attention.Lister's field and NewLister's and api.Register's parameter tickets → poller; a test's local tickets → open.
  • Decision 180 records the plan of time-tracking and its choices, which are the lead's, for the user's end review: the eleven steps; the shared client; how worklogs are read (/myself, a worklogAuthor search a day wider than the span, each ticket's worklogs filtered to mine); time polling 7 days every 5 minutes with no database, on port 8088; days in the pod's time zone, weeks Monday to Sunday, 8 hours a weekday; writes with Jira's defaults, starting at 09:00; time reusing todos' Jira settings and token on the laptop, whose homelab PR the user said may merge once its check is green.

QA

  • Gates: mise run --jobs 1 check green: Go lint 0 issues, govulncheck clean, Go coverage 95.7%; the web gates, with Vitest 1082 passed; E2E 319 passed, 7 skipped.
  • A pure move: git diff -M shows the client files as renames with only their import path changed, fetch.go and ticket.go unchanged, and FromEnv identical to jiraClient but for its constants' names.
  • Test inventory: 112 test functions before and after; the only difference is the four TestJiraClient* → TestFromEnv*.
  • Mutations: 22 mutants of FromEnv, the poller and todos' poll, run behind a dead HTTPS proxy so that a mutant can't call a real Jira. One survived at first: reading the token before checking the settings, since the rejection tests had the token. They now run without it, as pulls' do (decision 146), and all 22 are caught.

Review

No blocking findings. Non-blocking:

Merged under the user's standing OK once CI's check is green.

The time service will read and write worklogs on the same Jira site,
with the same settings and token as todos (decision 103), so the
client and the code that reads its settings move to the root
internal/jira. todos' poller of my tickets moves to its own package,
tickets. Nothing changes in behaviour. Decision 180 plans the rest of
time-tracking in eleven steps.
@Bakhomious
Bakhomious merged commit cdecd7f into main Oct 29, 2026
2 checks passed
@Bakhomious
Bakhomious deleted the step/shared-jira branch October 29, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant