pir_pipeline.utils.dashboard_utils.QuestionLinker¶
- class pir_pipeline.utils.dashboard_utils.QuestionLinker(data: list[dict], db: SQLAlchemyUtils, log: bool = True)¶
Bases:
objectQuestionLinker class to handle linking and unlinking of questions
- __init__(data: list[dict], db: SQLAlchemyUtils, log: bool = True)¶
QuestionLinker object to handle linking and unlinking of questions
- Args:
- data (dict): A series of instructions for linking/unlinking questions.
Should be of the form: [
- {
“link_type”: link or unlink, “base_question_id”: qid_1, “base_uqid”: uqid_1, “match_question_id”: qid_2, “match_uqid”: uqid_2
- {
…
}
]
db (SQLAlchemyUtils): SQLAlchemyUtils object for database interactions log (bool): Boolean to determin whether to write to changelog. Defaults to True.
Methods
__init__(data, db[, log])QuestionLinker object to handle linking and unlinking of questions
confirm()Mark a question as confirmed
get_ids()Return the ids from the present record.
link()Link two questions
log(changes)unlink()Unlink a question (or a single question-year) from its group.
Update links
- confirm()¶
Mark a question as confirmed
- get_ids()¶
Return the ids from the present record.
When the record carries a
base_year/match_year, the uqid lookup is narrowed to that(question_id, year)row. This matters under aquestion_idcollision, where the same question_id can sit under different uqids across years and a lookup by question_id alone would return an arbitrary one.
- link()¶
Link two questions
- unlink()¶
Unlink a question (or a single question-year) from its group.
When the record carries a
match_yearthe peel targets only that(question_id, year)row; otherwise every year ofmatch_qidis peeled out (the prior whole-question behavior). A peeled set of one row becomes unlinked (uqidNone); a multi-row set stays together under a fresh uqid. The group being unlinked from is dissolved if a single row is left behind, since a uqid should never group a lone question-year.
- update_links()¶
Update links
Makes calls to QuestionLinker.link and QuestionLinker.unlink as needed