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