feat: migrate Event and Reward models from MongoDB to CouchDB
- Replace Event model with CouchDB version using couchdbService - Replace Reward model with CouchDB version using couchdbService - Update event and reward routes to use new model interfaces - Handle participant management with embedded user data - Maintain status transitions for events (upcoming, ongoing, completed, cancelled) - Preserve catalog functionality and premium vs regular rewards - Update validators to accept CouchDB document IDs - Add rewards design document to couchdbService - Update test helpers for new model structure - Initialize CouchDB alongside MongoDB in server.js for backward compatibility - Fix linting issues in migrated routes 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
@@ -134,12 +134,20 @@ async function createTestEvent(userId, overrides = {}) {
|
||||
const defaultEvent = {
|
||||
title: 'Test Event',
|
||||
description: 'Test event description',
|
||||
date: new Date(Date.now() + 86400000), // Tomorrow
|
||||
date: new Date(Date.now() + 86400000).toISOString(), // Tomorrow
|
||||
location: 'Test Location',
|
||||
organizer: userId,
|
||||
};
|
||||
|
||||
const event = await Event.create({ ...defaultEvent, ...overrides });
|
||||
|
||||
// Add participant if userId is provided
|
||||
if (userId) {
|
||||
const user = await User.findById(userId);
|
||||
if (user) {
|
||||
await Event.addParticipant(event._id, userId, user.name, user.profilePicture || '');
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
@@ -150,10 +158,17 @@ async function createTestReward(overrides = {}) {
|
||||
const defaultReward = {
|
||||
name: 'Test Reward',
|
||||
description: 'Test reward description',
|
||||
pointsCost: 100,
|
||||
cost: 100,
|
||||
};
|
||||
|
||||
const reward = await Reward.create({ ...defaultReward, ...overrides });
|
||||
// Handle legacy field name mapping
|
||||
const rewardData = { ...defaultReward, ...overrides };
|
||||
if (rewardData.pointsCost && !rewardData.cost) {
|
||||
rewardData.cost = rewardData.pointsCost;
|
||||
delete rewardData.pointsCost;
|
||||
}
|
||||
|
||||
const reward = await Reward.create(rewardData);
|
||||
return reward;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user