import "server-only"; /** * SIHJantaParty — problem statements. * * The canonical list used to live in src/components/statements/statements-data.ts * and was duplicated three more times (teams-mock.ts PS_LIST, teams-create.tsx * EXTRA_PS_PAGES, and the landing page's PROBLEMS) across two mutually * incompatible id namespaces — SIH2026-001 named a different statement in two * of them. This collection is now the single source of truth; the authored * content from statements-data.ts was imported by scripts/import-statements.ts. * * Reference content, not seed data: these are real SIH statements, so the * import is idempotent (upsert on psId) and safe to re-run when the list * changes. */ import mongoose, { Schema, type Model, type InferSchemaType } from "mongoose"; const ProblemStatementSchema = new Schema( { psId: { type: String, required: true, unique: true }, // "SIH2026-001" title: { type: String, required: true }, organization: { type: String, required: true }, ministry: String, category: { type: String, enum: ["Software", "Hardware"], required: true }, theme: { type: String, required: true }, difficulty: { type: Number, enum: [1, 2, 3], required: true }, domain: { type: String, required: true }, description: { type: String, required: true }, background: { type: String, required: true }, expectedSolution: { type: String, required: true }, deliverables: { type: [String], default: [] }, tags: { type: [String], default: [] }, tint: { type: String, required: true }, datasetUrl: String, youtubeUrl: String, /** * NOTE: there is deliberately no `submittedTeams` field. The old hardcoded * counts (142, 98, 76 …) are replaced by a live aggregate over Team.psIds — * see countTeamsByPs() in src/lib/teams/dal.ts. Storing it would mean * keeping a counter in sync with every team create/delete/update. */ }, { timestamps: true, collection: "problem_statements" } ); ProblemStatementSchema.index({ title: "text", description: "text", tags: "text" }); ProblemStatementSchema.index({ theme: 1, difficulty: 1 }); ProblemStatementSchema.index({ category: 1 }); export type ProblemStatementDoc = InferSchemaType; export const ProblemStatement = (mongoose.models.ProblemStatement as Model) ?? mongoose.model("ProblemStatement", ProblemStatementSchema);