Removed tags and added cards
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user