Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 0 additions & 7 deletions src/pipelines/xlsform2lstsv/choiceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ export class ChoiceManager {

constructor(private fieldSanitizer: FieldSanitizer) {}

clear(): void {
this.choicesMap.clear();
this.answerCodeMap.clear();
this.questionToListMap.clear();
this.questionBaseTypeMap.clear();
}

getChoicesMap(): Map<string, ChoiceRow[]> {
return this.choicesMap;
}
Expand Down
7 changes: 0 additions & 7 deletions src/pipelines/xlsform2lstsv/counters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ export class Counters {
answerSeq = 0;
subquestionSeq = 0;

clear(): void {
this.groupSeq = 0;
this.questionSeq = 0;
this.answerSeq = 0;
this.subquestionSeq = 0;
}

setAnswerSeq(value: number): void {
this.answerSeq = value;
}
Expand Down
40 changes: 17 additions & 23 deletions src/pipelines/xlsform2lstsv/groupEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type GroupCounters = Counters;
/** Helpers passed to handleBeginGroup for name resolution + relevance. */
export interface GroupHelpers {
sanitizeName: (name: string) => string;
convertRelevance: (relevant?: string) => Promise<string>;
convertRelevance: (relevant?: string) => string;
}

/**
Expand All @@ -37,12 +37,6 @@ export class GroupEmitter {
private counters: GroupCounters,
) {}

clear(): void {
this.currentGroup = null;
this.groupStack = [];
this.pendingGroupNotes = [];
}

getCurrentGroup(): string | null {
return this.currentGroup;
}
Expand Down Expand Up @@ -89,11 +83,11 @@ export class GroupEmitter {
);
}

async addGroup(
addGroup(
row: SurveyRow,
sanitizeName: (name: string) => string,
convertRelevance: (relevant?: string) => Promise<string>,
): Promise<void> {
convertRelevance: (relevant?: string) => string,
): void {
const groupName =
row.name && row.name.trim() !== ''
? sanitizeName(row.name.trim())
Expand All @@ -105,7 +99,7 @@ export class GroupEmitter {
// type/scale is used as a stable group sequence key for LimeSurvey's TSV importer
// to correctly match group translations across languages.
const groupSeqKey = String(this.counters.getGroupSeq());
const relevance = await convertRelevance(row.relevant);
const relevance = convertRelevance(row.relevant);

this.rowEmitter.emitForEachLanguage(
(lang) => ({
Expand Down Expand Up @@ -149,18 +143,18 @@ export class GroupEmitter {
/**
* Emit pending parent-only group labels as note questions (type X).
*/
async emitPendingGroupNotes(
emitPendingGroupNotes(
sanitizeName: (name: string) => string,
convertRelevance: (relevant?: string) => Promise<string>,
): Promise<void> {
convertRelevance: (relevant?: string) => string,
): void {
for (const noteRow of this.pendingGroupNotes) {
const noteName =
noteRow.name && noteRow.name.trim() !== ''
? sanitizeName(noteRow.name.trim())
: `GN${this.counters.getQuestionSeq()}`;

this.counters.bumpQuestionSeq();
const relevance = await convertRelevance(noteRow.relevant);
const relevance = convertRelevance(noteRow.relevant);

this.rowEmitter.emitForEachLanguage((lang) => ({
class: 'Q',
Expand All @@ -185,13 +179,13 @@ export class GroupEmitter {
* note, do not emit.
* - otherwise: push, emit G row, flush pending notes.
*/
async handleBeginGroup(
handleBeginGroup(
row: SurveyRow,
isMessageOnly: boolean,
isParentOnly: boolean,
helpers: GroupHelpers,
onTableList: (sanitizedName: string) => Promise<void>,
): Promise<void> {
onTableList: (sanitizedName: string) => void,
): void {
const { sanitizeName, convertRelevance } = helpers;
const originalName = (row.name || '').trim();
const sanitizedName = originalName
Expand All @@ -208,9 +202,9 @@ export class GroupEmitter {
emittedAsGroup: true,
});
this.rowEmitter.flushGroupContent();
await this.addGroup(row, sanitizeName, convertRelevance);
await this.emitPendingGroupNotes(sanitizeName, convertRelevance);
await onTableList(sanitizedName);
this.addGroup(row, sanitizeName, convertRelevance);
this.emitPendingGroupNotes(sanitizeName, convertRelevance);
onTableList(sanitizedName);
return;
}

Expand Down Expand Up @@ -239,7 +233,7 @@ export class GroupEmitter {
emittedAsGroup: true,
});
this.rowEmitter.flushGroupContent();
await this.addGroup(row, sanitizeName, convertRelevance);
await this.emitPendingGroupNotes(sanitizeName, convertRelevance);
this.addGroup(row, sanitizeName, convertRelevance);
this.emitPendingGroupNotes(sanitizeName, convertRelevance);
}
}
5 changes: 0 additions & 5 deletions src/pipelines/xlsform2lstsv/groupProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ export class GroupProcessor {

constructor(private configManager: ConfigManager) {}

clear(): void {
this.messageOnlyGroups.clear();
this.parentOnlyGroups.clear();
}

getMessageOnlyGroups(): Set<string> {
return this.messageOnlyGroups;
}
Expand Down
Loading
Loading