Remove debug logging statements from utility functions and schema files to clean up code and improve performance. This includes the removal of console logs in parseFilter, filterDistributeKeys, normalizeFilterQuery, and the stockevent schema, streamlining the codebase for better maintainability.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good

This commit is contained in:
Tom Butcher 2026-08-30 12:26:08 +01:00
parent 6a730294b1
commit 5f59c23fbe
3 changed files with 6 additions and 13 deletions

View File

@ -1,6 +1,11 @@
import mongoose from 'mongoose'; import mongoose from 'mongoose';
import { generateId } from '../../utils.js'; import { generateId } from '../../utils.js';
import { getObject, editObject, aggregateRollups, aggregateRollupsHistory } from '../../database.js'; import {
getObject,
editObject,
aggregateRollups,
aggregateRollupsHistory,
} from '../../database.js';
const { Schema } = mongoose; const { Schema } = mongoose;
const parentStockModelNames = { const parentStockModelNames = {
@ -43,8 +48,6 @@ const buildParentState = (parentType, parentStock, currentAmount, startingAmount
const progress = currentAmount / startingAmount; const progress = currentAmount / startingAmount;
console.log('progress', progress);
if (currentAmount === startingAmount) { if (currentAmount === startingAmount) {
return { ...parentStock.state, type: fullState, progress: 1 }; return { ...parentStock.state, type: fullState, progress: 1 };
} }

View File

@ -137,6 +137,5 @@ export async function makeTradingRequest({
response: logResponse ? formatDebugPayload(xml) : undefined, response: logResponse ? formatDebugPayload(xml) : undefined,
}); });
console.log('xml', xml);
return xml; return xml;
} }

View File

@ -739,10 +739,6 @@ async function parseFilter(property, value, model = null) {
property = 'state.type'; property = 'state.type';
} }
console.log('property', property);
console.log('value', value);
console.log('model', model);
const fieldKind = getFilterFieldKind(property, model); const fieldKind = getFilterFieldKind(property, model);
const filterProperty = fieldKind.property; const filterProperty = fieldKind.property;
const isBoolField = isBooleanField(property, model); const isBoolField = isBooleanField(property, model);
@ -1282,7 +1278,6 @@ function filterDistributeKeys(value, keys = DISTRIBUTE_KEYS) {
result[key] = val; result[key] = val;
} }
} }
console.log('filterDistributeKeys', result);
return result; return result;
} }
@ -1676,10 +1671,6 @@ function normalizeFilterQuery(query = {}) {
// Returns a filter object based on allowed filters and req.query // Returns a filter object based on allowed filters and req.query
async function getFilter(query, allowedFilters, parse = true, model = null) { async function getFilter(query, allowedFilters, parse = true, model = null) {
const clauses = []; const clauses = [];
console.log('query', query);
console.log('allowedFilters', allowedFilters);
console.log('parse', parse);
console.log('model', model);
const queryClean = normalizeFilterQuery(query); const queryClean = normalizeFilterQuery(query);
for (const key of ['sortProperty', 'sortOrder', 'page', 'limit']) { for (const key of ['sortProperty', 'sortOrder', 'page', 'limit']) {
if (key in queryClean) delete queryClean[key]; if (key in queryClean) delete queryClean[key];