PointsHistory - IEEE-Team-3/map GitHub Wiki

Overview

The Points History keeps track of all points awarded to users throughout the app. It allows users and admins to view the total points earned and the reasons for those points.

History Structure

  • User ID: The ID of the user receiving the points
  • Points: The amount of points awarded
  • Type: The type of points (task, bonus, penalty, etc.)
  • Reason: The reason for awarding the points
  • Date: The date and time when the points were awarded

Example Schema

const PointsHistorySchema = new Schema({
  userId: { type: Schema.Types.ObjectId, ref: 'User' },
  points: { type: Number, required: true },
  type: { type: String, enum: ['task', 'bonus', 'penalty', 'achievement'] },
  reason: String,
  createdAt: { type: Date, default: Date.now }
});

Example Use Case

Users can view their points history through their profile, providing transparency on why they earned points.

Example Backend Logic

function getPointsHistory(userId) {
  return PointsHistory.find({ userId });
}
⚠️ **GitHub.com Fallback** ⚠️