127 lines · 4.0 KB
import { all, batch, first, run, stmt } from "./db";
import { randomId } from "./crypto";
import { allocateIssueNumber } from "./issues";
import type { IssueRow } from "./issues";
import { addIssueEvent } from "./pulls";

const MAX_CONVERTED_COMMENTS = 500;

export type DiscussionRow = {
  id: string;
  repo_id: string;
  number: number;
  category_id: string;
  author_id: string;
  title: string;
  body: string;
  answer_id: string | null;
  upvotes: number;
  comments_count: number;
  locked: number;
  created_at: number;
  updated_at: number;
};

export type CategoryRow = {
  id: string;
  repo_id: string;
  name: string;
  emoji: string;
  description: string;
  answerable: number;
};

const DEFAULT_CATEGORIES = [
  { name: "General", emoji: "💬", description: "Chat about anything", answerable: 0 },
  { name: "Q&A", emoji: "🙏", description: "Ask the community for help", answerable: 1 },
  { name: "Ideas", emoji: "💡", description: "Share ideas for new features", answerable: 0 },
  { name: "Announcements", emoji: "📣", description: "Updates from maintainers", answerable: 0 },
];