152 lines · 5.4 KB
import { all, first } from "./db";
import { withStore } from "./git/store";
import { repoInsights } from "./insights/repo-insights-do";
import { actorActivity, countableRepoSql, VERIFIED_EMAILS } from "./contributions";
import type { PrivateMode } from "./contributions";
import type { JsonValue } from "~/lib/types";

const DAY_MS = 24 * 60 * 60 * 1000;
export const DAY_REPOS_PAGE = 10;
export const DAY_ACTIVITY_PAGE = 20;
/** Commit subjects shown per repository; the rest are one click away in the repository's history. */
const SAMPLE_COMMITS = 3;

export type DayCommitRepo = {
  owner: string;
  name: string;
  commits: number;
  sample: Array<{ sha: string; subject: string }>;
};

export type DayActivity = {
  id: string;
  kind: string;
  data: { [key: string]: JsonValue };
  repo: { owner: string; name: string };
  createdAt: number;
};

export type ContributionDayDetail = {
  day: string;
  commitRepos: {
    items: DayCommitRepo[];
    total: number;
    page: number;
    hasMore: boolean;
  };
  activity: {
    items: DayActivity[];
    total: number;
    page: number;