Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kentcdodds/lineage

src/status.ts

32 lines · 816 B · TypeScript
import { bucket, getRepoSettings, ingestSummary, listCommentaries } from './storage.ts'

/**
 * Report storage fill status for the tracked repository.
 * Use this to see whether backfill still has work left.
 *
 * @returns Repo settings, stored commit counts, and commentary count
 *
 * @example
 * import status from 'kody:@kentcdodds/lineage/status'
 *
 * const snapshot = await status()
 */
export default async function status() {
	const [repo, ingest, commentaries, samples] = await Promise.all([
		getRepoSettings(),
		ingestSummary(),
		listCommentaries(),
		bucket().sql(
			`SELECT sha, counted_files, skipped_files, files_truncated
			 FROM commits
			 ORDER BY committed_at DESC
			 LIMIT 5`,
		),
	])
	return {
		repo,
		ingest,
		commentaryCount: commentaries.length,
		recentIngest: samples.rows,
	}
}