Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use a dash as a group delimiter anymore #5091

Merged
merged 19 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e3b42e1
Remove QPath from back-end code
noliveleger Aug 29, 2024
ed6401c
Remove QPath from front-end code
noliveleger Aug 29, 2024
97e8e57
Support advanced features JSON validation with qpath
noliveleger Aug 30, 2024
5583793
Refactoring
noliveleger Aug 31, 2024
9c1061a
Update formpack dependencies
noliveleger Sep 3, 2024
43ebf96
Merge branch 'beta-refactored' into TASK-539-remove-qpath
noliveleger Sep 3, 2024
2cf67ef
Update FormPack
noliveleger Sep 3, 2024
6723dd6
Fix isProcessingRouteActive having problems with "|" character
magicznyleszek Sep 4, 2024
48b4a81
further improve isProcessingRouteActive in some edge cases
magicznyleszek Sep 4, 2024
a04559c
Merge branch 'beta-refactored' into TASK-539-remove-qpath
noliveleger Sep 5, 2024
75adf96
Merge branch 'TASK-539-remove-qpath' of github.com:kobotoolbox/kpi in…
noliveleger Sep 5, 2024
ae79357
Merge branch 'beta-refactored' into TASK-539-remove-qpath
noliveleger Sep 5, 2024
4d127c3
Merge branch 'beta-refactored' into TASK-539-remove-qpath
noliveleger Sep 5, 2024
7d4edb0
Merge branch 'beta-refactored' into TASK-539-remove-qpath
noliveleger Sep 18, 2024
1098de0
Fix linter errors
noliveleger Sep 18, 2024
049d050
Merge branch 'beta-refactored' into TASK-539-remove-qpath
noliveleger Sep 18, 2024
5422e92
Apply requested changes
noliveleger Sep 19, 2024
fd6e61a
Improve repop_known_cols script efficiency to update data
noliveleger Sep 19, 2024
c178d7a
fix bug when supplementalDetails is empty if qpath is not present
noliveleger Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies/pip/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# via -r dependencies/pip/requirements.in
-e git+https://github.com/trevoriancox/django-dont-vary-on.git@01a804122b7ddcdc22f50b40993f91c27b03bef6#egg=django-dont-vary-on
# via -r dependencies/pip/requirements.in
-e git+https://github.com/kobotoolbox/formpack.git@451df4cd2a0d614be69a3b3309259c67369f7efb#egg=formpack
-e git+https://github.com/kobotoolbox/formpack.git@5a8cda8cc37a56a2313c98b88fcacc18049ef477#egg=formpack
# via -r dependencies/pip/requirements.in
-e git+https://github.com/dimagi/python-digest@5c94bb74516b977b60180ee832765c0695ff2b56#egg=python_digest
# via -r dependencies/pip/requirements.in
Expand Down
2 changes: 1 addition & 1 deletion dependencies/pip/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/bndr/pipreqs is a handy utility, too.

# formpack
-e git+https://github.com/kobotoolbox/formpack.git@451df4cd2a0d614be69a3b3309259c67369f7efb#egg=formpack
-e git+https://github.com/kobotoolbox/formpack.git@5a8cda8cc37a56a2313c98b88fcacc18049ef477#egg=formpack

# More up-to-date version of django-digest than PyPI seems to have.
# Also, python-digest is an unlisted dependency thereof.
Expand Down
2 changes: 1 addition & 1 deletion dependencies/pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# via -r dependencies/pip/requirements.in
-e git+https://github.com/trevoriancox/django-dont-vary-on.git@01a804122b7ddcdc22f50b40993f91c27b03bef6#egg=django-dont-vary-on
# via -r dependencies/pip/requirements.in
-e git+https://github.com/kobotoolbox/formpack.git@451df4cd2a0d614be69a3b3309259c67369f7efb#egg=formpack
-e git+https://github.com/kobotoolbox/formpack.git@5a8cda8cc37a56a2313c98b88fcacc18049ef477#egg=formpack
# via -r dependencies/pip/requirements.in
-e git+https://github.com/dimagi/python-digest@5c94bb74516b977b60180ee832765c0695ff2b56#egg=python_digest
# via -r dependencies/pip/requirements.in
Expand Down
17 changes: 8 additions & 9 deletions jsapp/js/assetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,17 +451,17 @@ export function findRow(assetContent: AssetContent, rowName: string) {
return assetContent?.survey?.find((row) => getRowName(row) === rowName);
}

export function findRowByQpath(assetContent: AssetContent, qpath: string) {
return assetContent?.survey?.find((row) => row.$qpath === qpath);
export function findRowByXpath(assetContent: AssetContent, xpath: string) {
return assetContent?.survey?.find((row) => row.$xpath === xpath);
}

export function getRowType(assetContent: AssetContent, rowName: string) {
const foundRow = findRow(assetContent, rowName);
return foundRow?.type;
}

export function getRowNameByQpath(assetContent: AssetContent, qpath: string) {
const foundRow = findRowByQpath(assetContent, qpath);
export function getRowNameByXpath(assetContent: AssetContent, xpath: string) {
const foundRow = findRowByXpath(assetContent, xpath);
if (foundRow) {
return getRowName(foundRow);
}
Expand Down Expand Up @@ -552,9 +552,8 @@ export function injectSupplementalRowsIntoListOfRows(
// Step 4: Inject all the extra columns immediately after source question
const outputWithCols: string[] = [];
output.forEach((col: string) => {
const qpath = col.replace(/\//g, '-');
outputWithCols.push(col);
(extraColsBySource[qpath] || []).forEach((extraCol) => {
(extraColsBySource[col] || []).forEach((extraCol) => {
outputWithCols.push(`_supplementalDetails/${extraCol.dtpath}`);
});
});
Expand Down Expand Up @@ -702,7 +701,7 @@ export function getAssetSubmissionProcessingUrl(
return undefined;
}

/** Returns a list of all rows (their `qpath`s) activated for advanced features. */
/** Returns a list of all rows (their `xpath`s) activated for advanced features. */
export function getAssetProcessingRows(assetUid: string) {
const foundAsset = assetStore.getAsset(assetUid);
if (foundAsset?.advanced_submission_schema?.properties) {
Expand All @@ -723,9 +722,9 @@ export function getAssetProcessingRows(assetUid: string) {
return undefined;
}

export function isRowProcessingEnabled(assetUid: string, qpath: string) {
export function isRowProcessingEnabled(assetUid: string, xpath: string) {
const processingRows = getAssetProcessingRows(assetUid);
return Array.isArray(processingRows) && processingRows.includes(qpath);
return Array.isArray(processingRows) && processingRows.includes(xpath);
}

export function isAssetProcessingActivated(assetUid: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,10 @@ export default class UserAssetPermsEditor extends React.Component<
false,
true
);
for (const [, qPath] of Object.entries(flatPaths)) {
for (const [, path] of Object.entries(flatPaths)) {
output.push({
value: qPath,
label: qPath,
value: path,
label: path,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function AnalysisContent() {

// We only want to display analysis questions for this survey question
const filteredQuestions = analysisQuestions.state.questions.filter(
(question) => question.qpath === singleProcessingStore.currentQuestionQpath
(question) => question.xpath === singleProcessingStore.currentQuestionXpath
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function AnalysisHeader() {
analysisQuestions?.dispatch({
type: 'addQuestion',
payload: {
qpath: singleProcessingStore.currentQuestionQpath,
xpath: singleProcessingStore.currentQuestionXpath,
type: definition.type,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type AnalysisQuestionsAction =
// Sets all the quetsion with new ones (useful for initialising)
| {type: 'setQuestions'; payload: {questions: AnalysisQuestionInternal[]}}
// Creates a draft question of given type with new uid assigned
| {type: 'addQuestion'; payload: {qpath: string; type: AnalysisQuestionType}}
| {type: 'addQuestion'; payload: {xpath: string; type: AnalysisQuestionType}}
// Opens question for editing, i.e. causes the editor to be opened for given
// question
| {type: 'startEditingQuestion'; payload: {uuid: string}}
Expand Down Expand Up @@ -43,7 +43,7 @@ export type AnalysisQuestionsAction =
| {
type: 'updateResponseCompleted';
payload: {
qpath: string;
xpath: string;
apiResponse: SubmissionProcessingDataResponse;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const analysisQuestionsReducer: AnalysisQuestionReducerType = (
}

const newQuestion: AnalysisQuestionInternal = {
qpath: action.payload.qpath,
xpath: action.payload.xpath,
type: action.payload.type,
labels: {_default: ''},
uuid: newUuid,
Expand Down Expand Up @@ -186,7 +186,7 @@ export const analysisQuestionsReducer: AnalysisQuestionReducerType = (
}
case 'updateResponseCompleted': {
const newQuestions = applyUpdateResponseToInternalQuestions(
action.payload.qpath,
action.payload.xpath,
action.payload.apiResponse,
state.questions
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function AnalysisTab() {
await fetchGetUrl<SubmissionProcessingDataResponse>(processingUrl);

questions = applyUpdateResponseToInternalQuestions(
singleProcessingStore.currentQuestionQpath,
singleProcessingStore.currentQuestionXpath,
apiResponse,
questions
);
Expand Down
6 changes: 3 additions & 3 deletions jsapp/js/components/processing/analysis/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export interface AnalysisQuestionBase {
uuid: string;
options?: AnalysisQuestionOptions;
/** The survey question that this analysis questions is for. */
qpath: string;
xpath: string;
}

/** Analysis question definition from the asset's schema (i.e. from Back end) */
Expand Down Expand Up @@ -160,7 +160,7 @@ export interface SubmissionAnalysisResponse extends AnalysisQuestionBase {
* This is the payload of a request made to update a question response.
*/
export interface AnalysisResponseUpdateRequest {
[qpath: string]:
[xpath: string]:
| {
qual: AnalysisRequest[];
}
Expand All @@ -173,7 +173,7 @@ export interface AnalysisResponseUpdateRequest {
* response.
*/
export interface SubmissionProcessingDataResponse {
[qpath: string]: {
[xpath: string]: {
qual: AnalysisResponse[];
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function AnalysisQuestionsList() {
// hide them at this point (not filtering the whole list beforehand),
// because we need the indexes to match the whole list. And FYI all
// analysis questions live on a single list :)
if (question.qpath !== singleProcessingStore.currentQuestionQpath) {
if (question.xpath !== singleProcessingStore.currentQuestionXpath) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function IntegerResponseForm(props: IntegerResponseFormProps) {

updateResponseAndReducer(
analysisQuestions.dispatch,
question.qpath,
question.xpath,
props.uuid,
question.type,
response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function SelectMultipleResponseForm(
// Update endpoint and reducer
updateResponseAndReducer(
analysisQuestions.dispatch,
question.qpath,
question.xpath,
props.uuid,
question.type,
newResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function SelectOneResponseForm(
// Update endpoint and reducer
updateResponseAndReducer(
analysisQuestions.dispatch,
question.qpath,
question.xpath,
props.uuid,
question.type,
newResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function TagsResponseForm(props: TagsResponseFormProps) {
// Update endpoint and reducer
updateResponseAndReducer(
analysisQuestions.dispatch,
question.qpath,
question.xpath,
props.uuid,
question.type,
newTags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function TextResponseForm(props: TextResponseFormProps) {

updateResponseAndReducer(
analysisQuestions.dispatch,
question.qpath,
question.xpath,
props.uuid,
question.type,
response
Expand Down
18 changes: 9 additions & 9 deletions jsapp/js/components/processing/analysis/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function convertQuestionsFromInternalToSchema(
options: question.options,
choices: question.additionalFields?.choices,
scope: 'by_question#survey',
qpath: question.qpath,
xpath: question.xpath,
};
});
}
Expand All @@ -64,7 +64,7 @@ export function convertQuestionsFromSchemaToInternal(
): AnalysisQuestionInternal[] {
return questions.map((question) => {
const output: AnalysisQuestionInternal = {
qpath: question.qpath,
xpath: question.xpath,
uuid: question.uuid,
type: question.type,
labels: question.labels,
Expand All @@ -85,12 +85,12 @@ export function convertQuestionsFromSchemaToInternal(
* internal questions list using the API endpoint response.
*/
export function applyUpdateResponseToInternalQuestions(
qpath: string,
xpath: string,
updateResp: SubmissionProcessingDataResponse,
questions: AnalysisQuestionInternal[]
): AnalysisQuestionInternal[] {
const newQuestions = clonedeep(questions);
const analysisResponses = updateResp[qpath]?.qual || [];
const analysisResponses = updateResp[xpath]?.qual || [];
newQuestions.forEach((question) => {
const foundResponse = analysisResponses.find(
(analResp) => question.uuid === analResp.uuid
Expand Down Expand Up @@ -191,15 +191,15 @@ export async function updateSurveyQuestions(
async function updateResponse(
processingUrl: string,
submissionUid: string,
qpath: string,
xpath: string,
analysisQuestionUuid: string,
analysisQuestionType: AnalysisQuestionType,
newResponse: string | string[] | number | null
) {
try {
const payload: AnalysisResponseUpdateRequest = {
submission: submissionUid,
[qpath]: {
[xpath]: {
qual: [
{
uuid: analysisQuestionUuid,
Expand All @@ -219,7 +219,7 @@ async function updateResponse(

return {
apiResponse: apiResponse,
qpath: qpath,
xpath: xpath,
};
} catch (err) {
return Promise.reject(err);
Expand All @@ -243,7 +243,7 @@ async function updateResponse(
*/
export async function updateResponseAndReducer(
dispatch: React.Dispatch<AnalysisQuestionsAction>,
surveyQuestionQpath: string,
surveyQuestionXpath: string,
analysisQuestionUuid: string,
analysisQuestionType: AnalysisQuestionType,
response: string | string[]
Expand Down Expand Up @@ -284,7 +284,7 @@ export async function updateResponseAndReducer(
const result = await updateResponse(
processingUrl,
singleProcessingStore.currentSubmissionEditId,
surveyQuestionQpath,
surveyQuestionXpath,
analysisQuestionUuid,
analysisQuestionType,
actualResponse
Expand Down
Loading
Loading