- Move AgentCategory from api/models to @packages/data-schemas structure

- Add schema, types, methods, and model following codebase conventions
  - Implement auto-seeding of default categories during AppService startup
  - Update marketplace controller to use new data-schemas methods
  - Remove old model file and standalone seed script
This commit is contained in:
Atef Bellaaj 2025-06-13 15:06:36 +02:00 committed by Danny Avila
parent 02f639f00e
commit 04008bf862
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
11 changed files with 126 additions and 242 deletions

View file

@ -1,6 +1,6 @@
const AgentCategory = require('~/models/AgentCategory');
const mongoose = require('mongoose');
const { logger } = require('~/config');
const { findCategoryByValue, getCategoriesWithCounts } = require('~/models');
// Get the Agent model
const Agent = mongoose.model('Agent');
@ -100,7 +100,7 @@ const getAgentsByCategory = async (req, res) => {
const result = await paginateAgents(filter, page, limit);
// Get category description from database
const categoryDoc = await AgentCategory.findOne({ value: category, isActive: true });
const categoryDoc = await findCategoryByValue(category);
const categoryInfo = {
name: category,
description: categoryDoc?.description || '',
@ -183,7 +183,7 @@ const searchAgents = async (req, res) => {
const getAgentCategories = async (_req, res) => {
try {
// Get categories with agent counts from database
const categories = await AgentCategory.getCategoriesWithCounts();
const categories = await getCategoriesWithCounts();
// Get count of promoted agents for Top Picks
const promotedCount = await Agent.countDocuments({