Tuesday, December 7, 2010

Per user tags and recent tags display

TODO: need per-user tags table
that will have uid -> array tag => count
update on every question user posts

===============================

How to find all questions AND answers per user per tag?

If we have tags in answers then it's easy just search for tag $in + $uid
then the same in QUESTIONS

So we really must have tags in ANSWERS!

===================================

Every time a user posts an answer we must also update PER_USER_TAGS collection

=====================================

It would be cool to have PER_USER_VIEWS table

question_id, uid, hts (i_ts not necessary because we can just sort by _id)

Can also collect "interesting tags" based on user views, questions, answers!

======================

Handling "save draft": best is to save draft into USER object under 'q_draft' as array
of title, body, tags

And for answer is a_draft and alo draft_c for comment!

Then after submit answer/question/comment but delete the value from user object

====================================

TODO: when showing "recent tags" Stack does sneaky thing:
it ALWAYS show "YOUR INTERESTING" tags first, even if they are not most recent
and THEN append block with recent tags.

In order to do this we cannot cache recent tags, actually we can for guests
and those who does not yet have "interesting tags"

Then we do 2 selects from RECENT_TAGS: first one with $in => "Interesting tags"
and the second one we get the usual 'recent tags' but remove "my tags" from result
OR specifically in find() pass $not and specify array of "interesting" tags.

It's probably easier to do the usual select, then array_diff
and then append one array to another or merge then so that "MY TAGS" are
always on top!

It actually goes one step beyond this: it also uses per-user tags stats, looks like it
picks some tags from there as well.

So 3 arrays: "My tags", "My stats tags" and "recent tags"
then filters out duplicates and uses them in order of "My tags", "Stat tags", "Recent tags"

Also, how are recent tags updated? Does the new answer trigger update or only new question?
In other words, recent activity for the tag, meaning answer/question/edit/comment (maybe?)
OR just new question?

==========================================

No comments:

Post a Comment