Skip to content

Commit

Permalink
Fix chain export advanced (#1546)
Browse files Browse the repository at this point in the history
* add reload after survey import

* add advanced

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
ramirobg94 and mergify[bot] authored Jun 29, 2021
1 parent 64a9848 commit 8bdade8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
7 changes: 3 additions & 4 deletions core/survey/_survey/surveyAnalysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export const getAnalysisNodeDefs =
let nodeDefs = SurveyNodeDefs.getNodeDefsArray(survey).filter(NodeDef.isAnalysis)

if (chain) {
nodeDefs = nodeDefs.filter(
(nodeDef) =>
NodeDef.getPropOrDraftAdvanced(NodeDef.keysPropsAdvanced.chainUuid)(nodeDef) === Chain.getUuid(chain)
)
nodeDefs = nodeDefs.filter((nodeDef) => {
return NodeDef.getPropOrDraftAdvanced(NodeDef.keysPropsAdvanced.chainUuid)(nodeDef) === Chain.getUuid(chain)
})
}

if (entity) {
Expand Down
11 changes: 8 additions & 3 deletions server/modules/analysis/service/rChain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ export const generateScript = async ({ surveyId, cycle, chainUuid, serverUrl })

// ==== READ
export const fetchEntityData = async ({ surveyId, cycle, entityDefUuid }) => {
const surveyAndNodeDefs = await SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId, cycle })
const surveyAndNodeDefs = await SurveyManager.fetchSurveyAndNodeDefsBySurveyId({
surveyId,
cycle,
advanced: true,
draft: true,
})

const query = Query.create({ entityDefUuid })

Expand All @@ -35,7 +40,7 @@ export const fetchEntityData = async ({ surveyId, cycle, entityDefUuid }) => {
// ==== UPDATE

export const persistResults = async ({ surveyId, cycle, entityDefUuid, chainUuid, filePath }) => {
const survey = await SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId, cycle })
const survey = await SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId, cycle, advanced: true, draft: true })
const chain = await AnalysisManager.fetchChain({
surveyId,
chainUuid,
Expand Down Expand Up @@ -93,7 +98,7 @@ export const persistUserScripts = async ({ user, surveyId, chainUuid, filePath }

const [chain, survey] = await Promise.all([
AnalysisManager.fetchChain({ surveyId, chainUuid, includeScript: true }, tx),
SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId }),
SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId, advanced: true, draft: true }),
])

const { root } = Survey.getHierarchy()(survey)
Expand Down
7 changes: 6 additions & 1 deletion server/modules/analysis/service/rChain/rChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ class RChain {
}

async _initSurveyAndChain() {
this._survey = await SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId: this.surveyId, cycle: this.cycle })
this._survey = await SurveyManager.fetchSurveyAndNodeDefsBySurveyId({
surveyId: this.surveyId,
cycle: this.cycle,
advanced: true,
draft: true,
})

const categories = await CategoryManager.fetchCategoriesAndLevelsBySurveyId({ surveyId: this.surveyId })
this._survey = Survey.assocCategories(categories)(this.survey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class ChainsValidationJob extends Job {
const { surveyId, tx } = this

const [survey, chains] = await Promise.all([
SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId, draft: true }, tx),
SurveyManager.fetchSurveyAndNodeDefsBySurveyId({ surveyId, draft: true, advanced: true }, tx),
AnalysisManager.fetchChains({ surveyId }, tx),
])

Expand Down

0 comments on commit 8bdade8

Please sign in to comment.