Perhaps if you broke it down a bit I could get what is going on. For
example, it looks like some pretty cool python syntax with. 
[t.tag for t in tags] I really can't understand what that does but it
looks cool. :P
I also didn't know you could use or operators in the limitby, spiffy.
Thanks for your help so far. :)
Best Regards,
Jason

On Fri, 2010-05-28 at 14:32 -0700, howesc wrote: 
> check out www.tenthrow.com, click on a concert and you will see an
> "other concerts" box.  those are generated following several rules,
> the first if finding concerts that share tags with this concert.  My
> tags have a "magnitude"  or a weighting, so some are more valued than
> others. hence the magnitude references below.  otherwise my tag and
> concert_tag tables mimic what you have in your model.  I don't display
> the tag name that they share though.
> 
> my relevant queries:
>     #active_playlist is a record, passed to my function.
>     tags = db(db.concert_tag.playlist== \
>  
> active_playlist.id).select(db.concert_tag.tag)
> 
>         count = db.concert_tag.id.count()
>         sum = db.concert_tag.magnitude.sum()
>         query = db((db.concert_tag.tag.belongs([t.tag for t in tags]))
> &
>                    (db.concert_tag.playlist != active_playlist.id) &
>                     (db.playlist.id == db.concert_tag.playlist) )
> 
>         rows = query.select(db.playlist.name,
>                             db.concert_tag.playlist,
>                             db.playlist.uid,
>                             count,
>                             sum,
>                             groupby=db.concert_tag.playlist|
>                                      db.playlist.uid,
>                             orderby=~count|~sum|~db.playlist.date,
>                             limitby=(0,NUM_RELATED_LINKS))
> 
> dunno if that helps or not...
> 
> 
> On May 28, 1:31 pm, Jason Brower <[email protected]> wrote:
> > I tried doing this last year and I was close and couldn't figure it out.
> > I need to complete implementing it and wondered if you could help out.
> > Using the attatched model I want to do the following:
> > I need to have a list of all the users that have similar tags to the
> > user that is logged in. I need those tag names as well.
> > As an added sugar candy bonus I wonder if there is an easy way to could
> > them or should I just count them as I sort throw them in the view.
> > I think I am close with this, it modified from something done last year.
> > Am I doing this right?
> > Best Regards,
> > Jason Brower
> >
> > My pertinent controller function:
> > ---
> >
> > @auth.requires_login()
> > def your_connections():
> >     related_tags = db((
> >
> > db.auth_user.id==db.user_tags.user_id)&(db.user_tags.tag_id==db.tag.id)&(db.user_tags.tag_id.belongs(
> >             db(db.user_tags.user_id==auth.user.id)._select(
> >                 db.user_tags.tag_id)))).select(
> >                     db.auth_user.ALL,db.tag.ALL,groupby=db.auth_user.id)
> >     return dict(related_tags = related_tags)
> > ---
> >
> >  db.py
> > 3KViewDownload


Reply via email to