Removed tags and added cards

This commit is contained in:
jackiettran
2025-07-31 23:35:49 -04:00
parent 8a02304da8
commit 209d8f5fbf
7 changed files with 768 additions and 822 deletions

View File

@@ -15,10 +15,6 @@ const Item = sequelize.define('Item', {
type: DataTypes.TEXT,
allowNull: false
},
tags: {
type: DataTypes.ARRAY(DataTypes.STRING),
defaultValue: []
},
pickUpAvailable: {
type: DataTypes.BOOLEAN,
allowNull: false,

View File

@@ -7,7 +7,6 @@ const router = express.Router();
router.get('/', async (req, res) => {
try {
const {
tags,
isPortable,
minPrice,
maxPrice,
@@ -19,10 +18,6 @@ router.get('/', async (req, res) => {
const where = {};
if (tags) {
const tagsArray = Array.isArray(tags) ? tags : [tags];
where.tags = { [Op.overlap]: tagsArray };
}
if (isPortable !== undefined) where.isPortable = isPortable === 'true';
if (minPrice || maxPrice) {
where.pricePerDay = {};
@@ -65,14 +60,9 @@ router.get('/recommendations', authenticateToken, async (req, res) => {
include: [{ model: Item, as: 'item' }]
});
const rentedTags = userRentals.reduce((tags, rental) => {
return [...tags, ...(rental.item.tags || [])];
}, []);
const uniqueTags = [...new Set(rentedTags)];
// For now, just return random available items as recommendations
const recommendations = await Item.findAll({
where: {
tags: { [Op.overlap]: uniqueTags },
availability: true
},
limit: 10,