Closed (fixed)
Project:
FriendList
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Sep 2008 at 07:03 UTC
Updated:
1 Nov 2009 at 22:10 UTC
Hi,
Please add the feature "people you might know already". This should be pretty straightforward to implement.
Merc.
Comments
Comment #1
mercmobily commentedHi,
The block is now there. It just doesn't return anything really meaningful.
I can't do much because 1) I don't have a site with significant data in it 2) I don't _actually_ know how to write a query for this (!).
I will ask the MySql mailing list once I have some data.
Merc.
Comment #2
hezlldp commentedI need this block for buddlist d5.somebody help me
Comment #3
mercmobily commentedHi,
Sorry, this module only exists for Drupal 6, and it has nothing to do with Buddylist.
Merc.
Comment #4
mercmobily commentedHi,
I need help.
Does anybody here know MySQL enough to actually make up the query for this block?
It's a _nasty_ one, and it's way over my head.
Help?
Merc.
Comment #5
mariusooms commentedHi...it seems work like this has been done for User_Relationships, it is best explained by this comment from sprsquish:
http://drupal.org/node/239162#comment-815753
Than a mysql query is provided by IceCreamYou in this comment:
http://drupal.org/node/239162#comment-888328
Finally here is actual block code for both mutual and possible relations provided by IceCreamYou:
http://drupal.org/node/239162#comment-968182
Could that be translated to friendlist?
Marius
Comment #6
mercmobily commentedHi,
I honestly don't know.
I am gonna contact Iscreamyou to see if he wants to write the query for us -- as I said, it's way beyond me.
Merc.
Comment #7
icecreamyou commentedHere's the thing, which I discovered after I fiddled around with the code I posted in that thread in an attempt to improve it on one of my sites. It's relatively simple to write a query that will grab users and order them by how many of the current user's friends know them. (Of course, I'd have to take a look at the DB structure to make sure.) However, to make it be really good at finding people you know, you also need to have it pay attention to profile fields (like city and workplace if they exist) and you need to be able to weight the fields (because you're more likely to know someone who works at the same place you do than you are to know someone who lives in the same country you do). And once we get into profile fields, we also need to pay attention to fields from Content Profile. And if you want to be able to weight fields, you need a UI, as well as much more complicated queries because you have to assign points for things so you can't just merge results...
The way SN sites do it that are written from scratch (Facebook, MySpace) is to keep separate tables that are chock-full of user-relationship data. Facebook's tables alone are something like hundreds of GB (!) IIRC.
So, if I have time, and if it's wanted, I'll look into writing a simple query that will just order users by second-degree relationship intensity (i.e. how many of your friends know someone else). Thoughts?
Comment #8
mariusooms commentedWhat you are explaining makes absolute sense...and man...on the SN site I am developing I use lots of core profile field data. Your theory would pay of huge for me, but I totally understand the complexity of it and would not fit for every user scenario and therefore would be too specific for this module.
From what I understand, the table structure of friendlist is fairly straight forward, however I'm no expert ;)
Your last solution might be just good enough for smaller SN sites, but could soon be not narrow enough since second-degree is most likely to happen fast with more users. However, it would be good to at least try it out and get this concept developed, since it is currently non-existent in Drupal (afaik). Who knows, it could be build on, but it has to start somewhere. I'd love it if we have something to experiment with, off course we couldn't do it without your help.
Let's see what Mercmobily thinks about this ;)
It would be great to try a query that list second-degree relationship intensity...where would we be without pioneering!
Regards,
Marius
(Co-maintainer friendlist)
PS. Thanks for chiming in IceCreamYou!
Comment #9
icecreamyou commentedOne thing I should add is that this experiment--in whatever form it ends up taking--will take a heavy performance toll as the number of users and relationships rise. This is especially true as complexity (in the form of profile/content-profile fields) is added due to cross-table lookups. So in terms of logistics, it may be better to have this as a submodule, just to keep the basics accessible to the maximum number of people.
Comment #10
mercmobily commentedHi,
This is the answer everybody expects: let's start small. Let's just start with checking the intensity of second-degree relationships. If I know 5 people, and they are all friends with Marius, then Marius should come up first in the list of people I might know.
This will get Version 1 of FriendList out of the door properly.
I think anything more than that will be soooo custom, and so dependent on the site, that it will need very custom SQL -- at which point they can hire Iscreamyou if they like.
Iscreamyou: please have a look at the current block... I think "all" it needs is a new query! (Which is a lot of effort, I know :-D ).
Bye,
Merc.
Comment #11
icecreamyou commentedIt's "IceCreamYou" actually, as in "Ice Cream" not "I Scream"... hehehe. Many of my Real Life (TM) friends call me Ice.
Anyway: conveniently enough, I think that the code I posted here will work for FriendList as well. All that needs to be changed is
{user_relationships}should be switched out with{friendlist_relations}, andAND (ur.approved = 1)should also be removed.I think you can handle it from there. The PHP needs a little cleaning up (I still needed to learn Drupal coding standards and functions when I wrote the code) but it's pretty basic stuff. You can leave out the
mysql_data_seeklines (Drupal does it for us) and remember to replace the RTID and hardcoded domain name appropriately.If it doesn't work or something doesn't make sense I'll of course be happy to look into it; but I can't test immediately.
Comment #12
icecreamyou commentedYou may also want to look at this - it's the beginning (well... most, actually) of a module I wrote for User Relationships that takes care of adding the blocks, settings, and related pages. There's some extraneous UR stuff in there though. And it was for D5, although that's not important for the non-system functions that actually do the work.
Comment #13
mercmobily commentedHi,
Ice: the difference I think is that in FriendList a mutual relationship is there when there are two records: one going from A to B, and one going from B to A. I don't _think_ this is true for UR.
Does that change the query?
Also... are you absolutely sure this couldn't be done with _one_ SQL query? (Or maybe two nested ones?)
Merc.
Comment #14
icecreamyou commentedIn UR, relationships can be either mutual or one-way, and that code is designed to work for mutual relationships; so no, it doesn't change anything.
Mmmhhph... I couldn't figure out how to do that when I wrote the code, but now I know about
IN()... :D try this. I haven't tested it.Comment #15
mercmobily commentedHi,
Let me clarify: I was talking about two way relationships. If FL, a two way relationship (like "friendship") _always_ has two records. One way ones (like "fan") only has one.
About testing... I don't actually have a working database of relations I can test this query for. It would be _grand_ if you could give this at least a bit of a test, and let us know... if it passes your preliminary tests, then I'd say others here (marius and other testers) could test it?
Thanks :-D
Merc.
Comment #16
icecreamyou commentedHmm. Well, I don't think the query will change, except that the first
u.uidmay need to be wrapped in DISTINCT().Just tested by replacing {friendlist_relations} with {user_relationships} (I don't have time to set up a friendlist testbed). It works, except that I left a whole lot of
ur's in the query when they should have been changed tofr. (I edited the comment and it's fixed now.)Cheers! I love it when things work the first time.
Comment #17
mercmobily commentedHi,
Thanks Ice.
Alright... now we can follow two routes.
I can just roll this in, and let people use it. At that point people with busy-ish sites will report problems if there are any.
I will do that, unless somebody here is willing to give it more of a test.
Anybody...?
Merc.
Comment #18
mercmobily commentedHi,
Alright, I committed the code. I have 0 results for now... let's see what happens.
Merc.
Comment #19
mercmobily commentedHi,
Marking this as fixed.
I am for the route of letting people use it and test it.
I added the avatar, but I am not suree how to resize it using the theme('user_picture') function... let's see.
Bye,
Merc.
Comment #20
mariusooms commentedHi Merc...I guess I was sleeping during this discussion...aha, the joys of timezone.
I will give it a spin and report any issues if I see any...thanks for the help IceCreamYou.
As far as resizing the avatar, there are actually already modules that do that, so it might not be necessary. The easiest solution for that would be to include a tiny css file and set the picture size there? It is easily overwritten with a custom picture size by the themer.
Regard,
Marius
Comment #21
mercmobily commentedHi,
Very true marius!
Merc.
Comment #22
mariusooms commentedHi,
Since this one is marked as fixed, after all the block _is_ created, I have opened a new issue for _problems_ ;)
Currently it is not accurately returning results: http://drupal.org/node/315189
Regards,
Marius
Comment #23
mercmobily commentedHi,
:-D
OK.
Ice, can you have a look?
Merc.
Comment #24
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #25
Allisone commented