added and fix some of things

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-08-03 12:03:02 +08:00
parent 6765c1faba
commit d246c09cdd
31 changed files with 724 additions and 510 deletions
+13
View File
@@ -2,6 +2,7 @@ const { Op } = require("sequelize");
const sequelize = require("../config/db.config");
const Sequelize = require("sequelize");
const R = require("../utils/response.util"); // adjust path as needed
const mdl_TierCategories = require("../models/tiers/tier_categories.mdl");
const auditByFields = ["createdBy", "updatedBy", "deletedBy"];
@@ -42,6 +43,18 @@ const getFieldValues = (Model, logTag, options = {}) => async (req, res) => {
return R.success(res, "Field values retrieved.", ["true", "false"]);
}
// ─── Tier gate fields — same reasoning as ENUM above: the picklist should
// reflect every tier category that exists, not just whichever ones a
// DISTINCT scan happens to find already assigned to a row.
if (field === "subscription") {
const categories = await mdl_TierCategories.findAll({
where: { is_active: true },
order: [["rank", "ASC"]],
raw: true,
});
return R.success(res, "Field values retrieved.", categories.map((c) => ({ value: c.slug, label: c.name })));
}
if (auditByFields.includes(field)) {
// Filtering must match the audit column's real (bigint) id — returning
// just the display name here previously made buildWhere() compare a