EnCiv / civil-pursuit

Other
8 stars 9 forks source link

api getWhyRanksAndPoints(discussionId,round, mostIds, leastIds, cb( {ranks: [], points: [] }) #207

Open ddfridley opened 2 months ago

ddfridley commented 2 months ago

see https://docs.google.com/spreadsheets/d/1hVsobuGFElsuzuKR0Hx4-htCmAQ-POFkHHt9ZGLcmZY/edit?gid=1364079177#gid=1364079177&range=C32:D32

getWhyRanksAndPoints(discussionId,round, mostIds, leastIds, cb( {ranks: [], whys: [] })

from rank, match userId, discussionId, stage: why, round.

If some found, fetch the correspoding why-points by the parentId in the rank.

if there is a why-point for all mostIds and leastIds then return ranks and whys

else get randomWhys for each mostId and leastId and return ranks and whys

ddfridley commented 2 weeks ago

@ldgze How is this going?

ldgze commented 1 week ago

@ldgze How is this going?

Hi David,

I’m still working on the issue and plan to commit the code later today.

ldgze commented 1 week ago

Hi David @ddfridley,

I have a question about when we should call randomWhys for each mostId and leastId. Specifically, do we need to call randomWhysonly when an ID has no existing "why," or should we ensure that each ID has at least 5 "whys" by calling randomWhys to make up any shortfall?

Just want to make sure I align with the requirements. Thanks for clarifying!

ddfridley commented 1 week ago

There may not be 5, then just get all there are.

⁣Get BlueMail for Android ​

On Nov 5, 2024, 12:51 PM, at 12:51 PM, Dongze Li @.***> wrote:

Hi David @ddfridley,

I have a question about when we should call randomWhys for each mostId and leastId. Specifically, do we need to call randomWhys only when an ID has no existing "why," or should we ensure that each ID has at least 5 "whys" by calling randomWhys to make up any shortfall?

Just want to make sure I align with the requirements. Thanks for clarifying!

-- Reply to this email directly or view it on GitHub: https://github.com/EnCiv/civil-pursuit/issues/207#issuecomment-2458127894 You are receiving this because you were mentioned.

Message ID: @.***>

ldgze commented 2 days ago

Hi David,

I’ve implemented the getWhyRanksAndPoints API based on my understanding of the requirements and have created a PR for it. However, I still need some clarifications to ensure everything aligns correctly.

Implementation Steps

  1. Fetch Ranks:
    Query ranks matching userId, discussionId, stage: 'why', and round.

  2. Extract Parent IDs from Ranks:
    Gather parentId values from the fetched ranks.

  3. Fetch Points Based on Parent IDs:
    Query the Points collection for why-points where parentId matches any of the parentIds from the ranks.

  4. Check if All mostIds and leastIds Have Corresponding Why-Points:

    • Step 4.1:
      If all mostIds and leastIds have corresponding why-points:
      • Return ranks and points (Currently, I’m returning the why-points fetched based on ranks, not specifically those matching mostIds and leastIds).
    • Step 4.2:
      If not all mostIds and leastIds have corresponding why-points:
      • Proceed to Step 5.
  5. Fetch Missing Whys Using getRandomWhys:
    For any missing mostIds or leastIds, fetch random whys using getRandomWhys.

My Questions

  1. For Step 4 and Step 5:

    • Should I return the why-points fetched based on ranks?
    • Or should I return the why-points matching the mostIds and leastIds?
  2. Test Case Relationship:

    • When writing test cases, how should I define the relationship between the why-points fetched according to the ranks and those matching the mostIds/leastIds?

Thanks for your time and guidance!