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

feat: updated api to allow ordering on endorsed status #425

Merged
merged 3 commits into from
Mar 25, 2024

Conversation

ayesha-waris
Copy link
Contributor

INF-1240

Add new param to cs_comment service threads api to allow ordering on endorsed status

Copy link

codecov bot commented Feb 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.19%. Comparing base (fb969c2) to head (9a1d9cc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #425      +/-   ##
==========================================
+ Coverage   96.16%   96.19%   +0.02%     
==========================================
  Files          58       58              
  Lines        4588     4624      +36     
==========================================
+ Hits         4412     4448      +36     
  Misses        176      176              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

spec/spec_helper.rb Show resolved Hide resolved
def check_thread_response_paging_json(thread, hash, resp_skip=0, resp_limit=nil, recursive=false, reverse_order=false)
check_thread_response_paging(thread, hash, resp_skip, resp_limit, true, recursive, reverse_order)
def check_thread_response_paging_json(thread, hash, resp_skip=0, resp_limit=nil, recursive=false, reverse_order=false, merge_question_type_responses=false)
check_thread_response_paging(thread, hash, resp_skip, resp_limit, true, recursive, reverse_order, merge_question_type_responses)
Copy link
Contributor

Choose a reason for hiding this comment

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

this new param passed is not taken as an input for the function check_thread_response_paging

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This parameter is intended to be used exclusively in the case of question-type threads. If provided, it serves to check whether the generated response matches that of a discussion-type thread."

spec/spec_helper.rb Show resolved Hide resolved
is_endorsed = num_comments > 0 && endorse_responses
hash = ThreadPresenter.new(thread, @reader, false, num_comments, is_endorsed, nil).to_hash(true, 0, default_resp_limit, true, false, true, true)
check_thread_result(@reader, thread, hash)
check_thread_response_paging(thread, hash, 0, default_resp_limit, false, false, true, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the same check we have for before this new param was added!
Can we be more specific in the test to check merge_question_type_responses params impact on the results returned! Right now, we are sort of only checking if we get a response or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

check_thread_response_paging is handling merge_question_type_responses impacts on the results returned

@@ -48,7 +49,8 @@ def to_hash(
end
sorting_key_order = reverse_order ? -1 : 1
if with_responses
if @thread.thread_type.discussion? && resp_skip == 0 && resp_limit.nil?
if (@thread.thread_type.discussion? || (@thread.thread_type.question? && merge_question_type_responses)) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this check mean now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The objective of this pull request (PR) is to ensure that the API responses for discussion type threads and question type threads are consistent. To achieve this, the check is to verify if the merge_question_type_responses parameter is present in the API call and if the thread type is a question. If both conditions are met, the API response for question type threads should match that of discussion type threads.

presenters/thread.rb Show resolved Hide resolved
Copy link
Contributor

@saadyousafarbi saadyousafarbi left a comment

Choose a reason for hiding this comment

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

Please squash and rebase before merge.

@ayesha-waris ayesha-waris merged commit 0dc490e into master Mar 25, 2024
16 checks passed
@ayesha-waris ayesha-waris deleted the Ayesha/INF-1240 branch March 25, 2024 08:59
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