Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- routes/search.js +4 -22
routes/search.js
CHANGED
|
@@ -25,28 +25,10 @@ router.get('/tutorial-tasks/:week', authenticateToken, async (req, res) => {
|
|
| 25 |
const weekNumber = parseInt(req.params.week);
|
| 26 |
|
| 27 |
const WeekBrief = require('../models/WeekBrief');
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
category: 'tutorial',
|
| 33 |
-
weekNumber: 2
|
| 34 |
-
}).sort({ position: 1, createdAt: 1 });
|
| 35 |
-
tasks = week2.map(doc => {
|
| 36 |
-
const obj = doc._doc || doc;
|
| 37 |
-
return {
|
| 38 |
-
...obj,
|
| 39 |
-
weekNumber: 1,
|
| 40 |
-
title: typeof obj.title === 'string' ? obj.title.replace('Week 2', 'Week 1') : obj.title,
|
| 41 |
-
_id: obj._id // preserve _id shape for frontend list keys; data identity remains from week2
|
| 42 |
-
};
|
| 43 |
-
});
|
| 44 |
-
} else {
|
| 45 |
-
tasks = await SourceText.find({
|
| 46 |
-
category: 'tutorial',
|
| 47 |
-
weekNumber: weekNumber
|
| 48 |
-
}).sort({ position: 1, createdAt: 1 });
|
| 49 |
-
}
|
| 50 |
// Check hidden flag; if hidden and user not admin, return empty
|
| 51 |
const wb = await WeekBrief.findOne({ category: 'tutorial', weekNumber });
|
| 52 |
const role = (req.headers['user-role'] || 'visitor').toString();
|
|
|
|
| 25 |
const weekNumber = parseInt(req.params.week);
|
| 26 |
|
| 27 |
const WeekBrief = require('../models/WeekBrief');
|
| 28 |
+
const tasks = await SourceText.find({
|
| 29 |
+
category: 'tutorial',
|
| 30 |
+
weekNumber: weekNumber
|
| 31 |
+
}).sort({ position: 1, createdAt: 1 });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
// Check hidden flag; if hidden and user not admin, return empty
|
| 33 |
const wb = await WeekBrief.findOne({ category: 'tutorial', weekNumber });
|
| 34 |
const role = (req.headers['user-role'] || 'visitor').toString();
|