File size: 2,468 Bytes
78664f6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 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<typeof ProblemStatementSchema>;
export const ProblemStatement =
(mongoose.models.ProblemStatement as Model<ProblemStatementDoc>) ??
mongoose.model<ProblemStatementDoc>("ProblemStatement", ProblemStatementSchema);
|