community-platform icon indicating copy to clipboard operation
community-platform copied to clipboard

Questions: Add votedUsefulQuestions to user model

Open benfurber opened this issue 10 months ago • 4 comments

Like votedUsefulResearch and votedUsefulHowtos, the questions a user has voted useful should be saved too.

As it's likely more content types will get the useful feature in the future, now might be the time to nest all the voted useful in a single field on the user rather than as seperate ones. A mod can do the db migrations to accomidate this.

benfurber avatar Apr 17 '24 07:04 benfurber

Currently, the voteUsefulBy is tracked in the Research/HowTo/Question objects using the ISharedFeatures extends IVotedUseful interface, not in the user object.

Would you prefer to link this feature only to the user, or to both the user and the article?

The advantage of keeping it in the article object is that you don't need to retrieve the user object to check if they marked the article as useful.

If we decide to keep the voteUseful information in both the user and the article, I suggest updating the user via a Cloud Function that detects article updates and makes the necessary updates to the user object.

goratt12 avatar May 18 '24 18:05 goratt12

Pros for keeping voteUsefulBy in the article:

  • simple solution to list who voted for the article

Cons:

  • we don't have that feature now
  • listing articles requires more bandwidth with the growing number of votes

So I think we could remove it from the articles and instead have a list of voted articles in the user profile.

As for the solution, we want to move away from having the client update the article directly (votedBy and totalVotes), as it requires everyone to have write access. Since we already have an API, maybe we could use it for this :)

mariojsnunes avatar May 19 '24 02:05 mariojsnunes

Until we have a clearer plan about what's next for the API, let's got with a cloud function approach.

Considering our document approach at the moment, I'm not concerned about duplicate data as long as the cloud functions copy from the source of truth into other appropriate docs.

Keeping the ISharedFeatures is probably good. I'd like as much uniformity across our data structure as we can manage! And bandwidth is well under control now.

benfurber avatar May 21 '24 07:05 benfurber

Noticed this discussion when flicking through emails. A little background... the voted useful used to sit on the user object but it was leading to incorrect useful counts being displayed.

The aggregation had to count through all of the user objects when there was a change to get the current count and it wasn't particularly performant, we'd end up with different clients overwriting each others updates etc.

I've not caught up with recent architectural changes in the code base yet but obviously an api + rdbms would be useful for solving all the issues raised in this thread but for now I agree with @benfurber.

iSCJT avatar May 21 '24 08:05 iSCJT