usecase

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckCycleState

type CheckCycleState struct {
	KnownPRs      map[string]bool
	KnownReviews  map[string]map[string]*pullrequest.Review
	ReviewsSeeded bool
}

CheckCycleState carries all state that must persist between polling cycles. It is owned by the orchestrator and threaded through each Execute call.

func NewCheckCycleState

func NewCheckCycleState() CheckCycleState

NewCheckCycleState returns a freshly initialised CheckCycleState.

type CheckNewPullRequestsUseCase

type CheckNewPullRequestsUseCase struct {
	// contains filtered or unexported fields
}

CheckNewPullRequestsUseCase handles fetching and detecting new PRs Emits domain events for new PRs instead of directly sending notifications

func NewCheckNewPullRequestsUseCase

func NewCheckNewPullRequestsUseCase(
	prRepo pullrequest.PullRequestRepository,
	trackingRepo pullrequest.PRTrackingRepository,
	prFilter pullrequest.FilterFn,
	eventPublisher port.EventPublisher,
) *CheckNewPullRequestsUseCase

NewCheckNewPullRequestsUseCase creates a new use case

func (*CheckNewPullRequestsUseCase) Execute

func (uc *CheckNewPullRequestsUseCase) Execute(
	ctx context.Context,
	state CheckCycleState,
	previousCycleAt time.Time,
) (*PRCheckResult, CheckCycleState, error)

Execute fetches PRs and detects new ones. It accepts the current inter-cycle state and returns the updated state for the next cycle together with the fetched PRs for use by other use cases.

type DetectClosedPullRequestsUseCase

type DetectClosedPullRequestsUseCase struct {
	// contains filtered or unexported fields
}

DetectClosedPullRequestsUseCase detects PRs that have been merged or closed by comparing the current fetch results against the set of open PRs persisted at the end of the previous check cycle.

When a tracked PR disappears from the open PR list it queries GitHub for the final status and emits the appropriate domain events.

Tracking cleanup (e.g. removing from seen state) is handled by event handlers subscribed to Merged and Closed events.

func NewDetectClosedPullRequestsUseCase

func NewDetectClosedPullRequestsUseCase(
	prRepo pullrequest.PullRequestRepository,
	trackingRepo pullrequest.PRTrackingRepository,
	eventPublisher port.EventPublisher,
) *DetectClosedPullRequestsUseCase

NewDetectClosedPullRequestsUseCase creates a new use case.

func (*DetectClosedPullRequestsUseCase) Execute

func (uc *DetectClosedPullRequestsUseCase) Execute(ctx context.Context, currentPRs []*pullrequest.PullRequest) ([]string, error)

Execute compares the current open PR list against the previously-saved snapshot set to detect merged/closed PRs. Returns a list of closed/merged PR URLs so the caller can clean up cycle state (KnownPRs, KnownReviews).

After detection, currentPRs is always persisted as the new snapshot for the next cycle — no separate tracking call is required from the caller.

type InitializeFirstCheckUseCase

type InitializeFirstCheckUseCase struct {
	// contains filtered or unexported fields
}

InitializeFirstCheckUseCase handles the first-run initialization On first run, all existing PRs are marked as seen to avoid notifications

func NewInitializeFirstCheckUseCase

func NewInitializeFirstCheckUseCase(
	prRepo pullrequest.PullRequestRepository,
	prTrackingRepo pullrequest.PRTrackingRepository,
	prFilter pullrequest.FilterFn,
	uiPort port.UIPort,
) *InitializeFirstCheckUseCase

NewInitializeFirstCheckUseCase creates a new use case

func (*InitializeFirstCheckUseCase) Execute

Execute runs the first-run initialization. Returns (true, allPRs, nil) on the first run ever, where allPRs contains all currently-open PRs that were marked as seen. The caller should use allPRs to seed any stateful use cases (e.g. pipeline-status tracking) so that the first regular check does not re-fire change events for every existing PR. Returns (false, nil, nil) when the tracking store is already populated.

type PRCheckResult

type PRCheckResult struct {
	RequestedReviewPRs []*pullrequest.PullRequest
	UserCreatedPRs     []*pullrequest.PullRequest
}

PRCheckResult contains the results of checking for new PRs

type TrackPullRequestActivityUseCase

type TrackPullRequestActivityUseCase struct {
	// contains filtered or unexported fields
}

TrackPullRequestActivityUseCase handles checking for new activity on PRs. Uses a two-tier scheduling strategy to optimize API calls.

Enrichment state (head-commit SHA, pipeline status, last-activity check timestamp) is persisted via PRTrackingRepository so that it survives process restarts and is also shared with DetectClosedPullRequestsUseCase, which merges this data into the snapshots it saves each cycle.

func NewTrackPullRequestActivityUseCase

func NewTrackPullRequestActivityUseCase(
	prRepo pullrequest.PullRequestRepository,
	trackingRepo pullrequest.PRTrackingRepository,
	scheduler *pullrequest.ActivityCheckScheduler,
	eventPublisher port.EventPublisher,
	authenticatedUser string,
) *TrackPullRequestActivityUseCase

NewTrackPullRequestActivityUseCase creates a new use case. authenticatedUser is the GitHub login of the current user; self-authored activities are not considered "new activity" for the purposes of marking PRs as unseen.

func (*TrackPullRequestActivityUseCase) Execute

func (uc *TrackPullRequestActivityUseCase) Execute(
	ctx context.Context,
	prs []*pullrequest.PullRequest,
	lastCheckTime time.Time,
) error

Execute checks for new activity on PRs using two-tier scheduling. Only checks PRs that are due based on the scheduling strategy.

func (*TrackPullRequestActivityUseCase) UpdateIgnoreConfig

func (uc *TrackPullRequestActivityUseCase) UpdateIgnoreConfig(cfg *pullrequest.IgnoreConfig)

UpdateIgnoreConfig atomically replaces the active ignore config used to decide whether a PR should be marked as unseen. Safe to call from any goroutine.

type UpdatePullRequestDisplayUseCase

type UpdatePullRequestDisplayUseCase struct {
	// contains filtered or unexported fields
}

UpdatePullRequestDisplayUseCase handles updating the UI with current PR state

func NewUpdatePullRequestDisplayUseCase

func NewUpdatePullRequestDisplayUseCase(
	uiPort port.UIPort,
	prTrackingRepo pullrequest.PRTrackingRepository,
) *UpdatePullRequestDisplayUseCase

NewUpdatePullRequestDisplayUseCase creates a new use case

func (*UpdatePullRequestDisplayUseCase) Execute

func (uc *UpdatePullRequestDisplayUseCase) Execute(ctx context.Context, requestedReviewPRs []*pullrequest.PullRequest,
	userCreatedPRs []*pullrequest.PullRequest,
) error

Execute updates the UI display with the given PRs PRs are sorted by creation date (oldest first) before display

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL