Skip to content

Support answering stage questions and bulk article customizations - #53

Open
amamd07 wants to merge 5 commits into
masterfrom
tasks/11048
Open

Support answering stage questions and bulk article customizations#53
amamd07 wants to merge 5 commits into
masterfrom
tasks/11048

Conversation

@amamd07

@amamd07 amamd07 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Extends ReviewCustomizations (rayyan/reviews/customizations.py) to cover both shapes of the /customize endpoint.

  • customize() gains optional scope and allow_string_value, so a customization can target a specific question's answer_key.
  • answer_question(id, article_id, stage_id, question_id, answer, key="included", allow_string_value=True) — encodes a single value or list into the plan shape the API expects. The question's answer_key (scope) is built inside the SDK from stage_id/question_id via stage_question_answer_key() / STAGE_QUESTION_ANSWER_KEY_TEMPLATE, so callers never assemble the key format themselves.
  • bulk_customizations() now accepts article_ids as a list/tuple or comma-separated string and normalizes to the comma-separated string the endpoint requires.
  • set_label() and set_reason() — add/remove a label or exclusion reason. Both delegate to a shared _set_customization helper: value=1 (add) uses the bulk params form in one request; value=-1 (remove) uses the per-article plan form, applied to each article. This sets the given key rather than toggling — other customizations already on an article are left unchanged. The __EXR__ reason prefix and the remove value live in named constants (EXCLUSION_REASON_PREFIX, REMOVE_VALUE).
  • Package version bumped 1.0rc16 → 1.0rc17 (setup.cfg).

No breaking changes — all new parameters are optional and existing signatures are preserved. Note: set_label/set_reason return a single response when adding and a list of per-article responses when removing.

@amamd07
amamd07 requested review from hammady and maboelnour July 23, 2026 22:32
Comment thread rayyan/reviews/customizations.py Outdated
params = {"key": key, "value": value, "article_ids": article_ids}
return self._request("POST", f"{REVIEWS_ROUTE}/{id}/customize", params=params)

def _toggle_customization(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an article already has a customization and this method is called to add a new one, the existing customization won't be toggled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, I had the decision customization in mind. I've renamed it to _set_customization and updated the docstring to note it sets the key rather than toggling.

Comment thread rayyan/reviews/customizations.py Outdated

The question belongs to a stage, so ``scope`` is the question's
``answer_key`` (of the form
``__SYSTEM__STAGE__<stage_id>__QUESTION__<question_id>``). ``answer`` is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this form be in a constant?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was only for clarification. But your comment got me thinking that the construction belongs to the sdk. I moved the construction here and created a template and helper that constructs it. Thanks!

@hammady
hammady removed their request for review July 27, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants