Django Aggregate(annotate, count) is working differently.

2020-06-17 Thread Himanshu Pharawal
models.py class Intrest(models.Model): user = models.ForeignKey(User, related_name='intrests', on_delete=models. CASCADE) keyword = models.CharField(max_length=100) class SponsoredBook(models.Model): title = models.CharField(max_length=20) class Keyword(models.Model): sponsored_book = models.

Re: I need to know how to optimize this?

2020-06-15 Thread Himanshu Pharawal
keywords__title')).filter(tit__in=sub).annotate(points=Count('id')). order_by('-points', '-bid')[:6] On Sunday, June 14, 2020 at 11:26:10 AM UTC+5:30, Himanshu Pharawal wrote: > > Yes your assumptions are right. > I am sorry for irrelevant models code i

Re: I need to know how to optimize this?

2020-06-13 Thread Himanshu Pharawal
e for recommendations) > specific to every user. I see that you are calculating these are runtime > does that mean the user interests are too volatile ? > > I think these things could clear things up > > > On Saturday, June 13, 2020 at 8:18:29 PM UTC+5:30, Himanshu Ph

I need to know how to optimize this?

2020-06-13 Thread Himanshu Pharawal
# This code is use for match the interests of current user to saved SponsoredBook-keywords # If same book match with two keywords we increase it's priority by increasing it's points and finally sort them on the basis of their points #Please reach out to me if you need more information on the sam

I need to know how to optimize this?

2020-06-13 Thread Himanshu Pharawal
#This code is use to match current user interests to SponsoredBook.keywords and if it matches more than one keyword we increase it's points and finally we sort this on the basis of points and pass it to the templates. #For a small amount of data this works fine as will data will grow this is goi