fix(submissions): remove User model populate calls
- User is also a native MongoDB class, not Mongoose model - Removed all .populate() calls for createdBy, lastUpdatedBy, notes.author - These were causing MissingSchemaError for User model - Submissions can be returned without populated user data
This commit is contained in:
parent
28c1481e6b
commit
eb8d59da25
2 changed files with 13 additions and 19 deletions
|
|
@ -43,8 +43,8 @@
|
|||
"last_deliberation": null
|
||||
},
|
||||
"FileEditHook": {
|
||||
"timestamp": "2025-10-23T21:24:52.570Z",
|
||||
"file": "/home/theflow/projects/tractatus/src/models/Analytics.model.js",
|
||||
"timestamp": "2025-10-23T21:31:02.525Z",
|
||||
"file": "/home/theflow/projects/tractatus/src/controllers/submissions.controller.js",
|
||||
"result": "passed"
|
||||
},
|
||||
"FileWriteHook": {
|
||||
|
|
@ -58,25 +58,25 @@
|
|||
"tokens": 30000
|
||||
},
|
||||
"alerts": [],
|
||||
"last_updated": "2025-10-23T21:24:52.570Z",
|
||||
"last_updated": "2025-10-23T21:31:02.525Z",
|
||||
"initialized": true,
|
||||
"framework_components": {
|
||||
"CrossReferenceValidator": {
|
||||
"message": 0,
|
||||
"tokens": 0,
|
||||
"timestamp": "2025-10-23T21:27:54.923Z",
|
||||
"last_validation": "2025-10-23T21:27:54.923Z",
|
||||
"validations_performed": 706
|
||||
"timestamp": "2025-10-23T21:31:14.843Z",
|
||||
"last_validation": "2025-10-23T21:31:14.843Z",
|
||||
"validations_performed": 712
|
||||
},
|
||||
"BashCommandValidator": {
|
||||
"message": 0,
|
||||
"tokens": 0,
|
||||
"timestamp": null,
|
||||
"last_validation": "2025-10-23T21:27:54.924Z",
|
||||
"validations_performed": 362,
|
||||
"last_validation": "2025-10-23T21:31:14.844Z",
|
||||
"validations_performed": 365,
|
||||
"blocks_issued": 37
|
||||
}
|
||||
},
|
||||
"action_count": 362,
|
||||
"action_count": 365,
|
||||
"auto_compact_events": []
|
||||
}
|
||||
|
|
@ -81,10 +81,9 @@ async function getSubmissions(req, res) {
|
|||
if (status) query.status = status;
|
||||
if (publicationId) query.publicationId = publicationId;
|
||||
|
||||
// NOTE: BlogPost is a native MongoDB class, not a Mongoose model,
|
||||
// so we can't use .populate() for blogPostId. Fetch blog post data separately if needed.
|
||||
// NOTE: BlogPost and User are native MongoDB classes, not Mongoose models,
|
||||
// so we can't use .populate() for them. Fetch data separately if needed.
|
||||
const submissions = await SubmissionTracking.find(query)
|
||||
.populate('createdBy', 'email')
|
||||
.sort({ submittedAt: -1, createdAt: -1 })
|
||||
.limit(parseInt(limit, 10))
|
||||
.skip(parseInt(offset, 10));
|
||||
|
|
@ -137,10 +136,7 @@ async function getSubmissionById(req, res) {
|
|||
try {
|
||||
const { id } = req.params;
|
||||
|
||||
const submission = await SubmissionTracking.findById(id)
|
||||
.populate('createdBy', 'email')
|
||||
.populate('lastUpdatedBy', 'email')
|
||||
.populate('notes.author', 'email');
|
||||
const submission = await SubmissionTracking.findById(id);
|
||||
|
||||
if (!submission) {
|
||||
return res.status(404).json({
|
||||
|
|
@ -318,9 +314,7 @@ async function getSubmissionByBlogPost(req, res) {
|
|||
try {
|
||||
const { blogPostId } = req.params;
|
||||
|
||||
const submission = await SubmissionTracking.findOne({ blogPostId })
|
||||
.populate('createdBy', 'email')
|
||||
.populate('lastUpdatedBy', 'email');
|
||||
const submission = await SubmissionTracking.findOne({ blogPostId });
|
||||
|
||||
if (!submission) {
|
||||
return res.status(404).json({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue