-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(survey): add support for additional attributes on model
- Loading branch information
1 parent
5ce0305
commit 3691142
Showing
10 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
exports.address = require('./address'); | ||
exports.surveyAddressState = require('./surveyAddressState'); | ||
exports.SurveyAddress = require('./surveyAddress'); | ||
exports.SurveyAddressAdditionalAttributes = require('./surveyAddressAdditionalAttributes'); | ||
exports.surveyAddressState = require('./surveyAddressState'); | ||
exports.SurveyDump = require('./surveyDump'); | ||
exports.SyncLog = require('./syncLog'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const logger = require('../helpers/logger'); | ||
|
||
const surveyAddressFile = path.resolve('./model/surveyAddress.js'); | ||
|
||
if (fs.existsSync(surveyAddressFile)) { | ||
logger.info('Loading SurveyAddress additional attributes...'); | ||
module.exports = require(surveyAddressFile); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
exports.StatusService = require('./status'); | ||
exports.SurveyService = require('./survey'); | ||
exports.SyncService = require('./sync'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const {forEach, keys} = require('lodash'); | ||
|
||
const {SurveyAddressAdditionalAttributes, surveyAddressState} = require('../model'); | ||
|
||
class SurveyService { | ||
static assign(surveyAddress, survey) { | ||
surveyAddress.surveyAddressState = survey.closed ? surveyAddressState.RESOLVED : surveyAddressState.IN_PROGRESS; | ||
surveyAddress.dwellings = survey.dwellings; | ||
surveyAddress.valid = survey.valid; | ||
|
||
forEach( | ||
keys(SurveyAddressAdditionalAttributes), | ||
key => { | ||
surveyAddress[key] = survey[key]; | ||
} | ||
); | ||
} | ||
} | ||
|
||
module.exports = SurveyService; |