const asyncHandler = require("../middlewares/asyncHandler");
const { getActivityLog } = require("../repositories/activityLogRepository");

/**
 * GET /api/activity-log
 * Returns unified activity log from users_logs, sat_form_logs, tickets_logs.
 * Query: limit (optional, default 500, max 1000)
 */
exports.getActivityLog = asyncHandler(async (req, res) => {
  const limit = req.query.limit;
  const activities = await getActivityLog(limit);
  res.status(200).json({ success: true, data: activities });
});
