Skip to content

Commit

Permalink
Merge pull request #2986 from LiteFarmOrg/LF-3821-failure-when-editin…
Browse files Browse the repository at this point in the history
…g-greenhouse-details

LF-3821 Failure when editing greenhouse details
  • Loading branch information
SayakaOno authored Nov 15, 2023
2 parents 591d736 + 36da5f6 commit 8dcc76c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/api/src/models/greenhouseModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ import Model from './baseFormatModel.js';
import organicHistoryModel from './organicHistoryModel.js';

class Greenhouse extends Model {
// Code from gardenModel.js and fieldModel.js
// Converts datetimes to date strings by stripping the time component
$parseJson(json, opt) {
json = super.$parseJson(json, opt);
const pgDateTypeFields = ['transition_date'];
if (Object.keys(json).some((e) => pgDateTypeFields.includes(e))) {
Object.keys(json).forEach((key) => {
if (pgDateTypeFields.includes(key) && json[key]) {
json[key] = json[key].split('T')[0];
}
});
}
return json;
}

static get tableName() {
return 'greenhouse';
}
Expand Down

0 comments on commit 8dcc76c

Please sign in to comment.