The point is that there is a way, in fact multiple ways that this could be 
implemented without changing the models. A change to the method I suggested in 
my last mail would be to avoid looping over the query set at all or even the 
Entry() class and using values and the the Count() annotation in a single query 
and instead of showing the repr of the object deleted we could say something 
like “Deleted 1item” or “Deleted 10 items” which on click could show us the 
group of items being talked about. 

Akshat: I’m not sure how you plan on grouping the query set appropriately using 
javascript. I don’t think that is implementable. And even if it is, I don’t see 
how it would be more efficient.

Carles Pina I Estany: While I understand what you’re trying to do I don’t know 
why we are trying to avoid COUNT is there a best practice associated with this 
that I don’t know about?
However I do see a concern in adding a loop to the queryset right there in 
python. A slightly better solution would be simply saying 
Entries = 
LogEntry.objects.values(‘action_time’,’action_flag’,’user’).annotate(no_of_items
 = Count(‘id’)) and switching up things like 
{{ entry.object_repr }} in index.html to accommodate the dictionary that will 
be returned so that recent actions doesn’t deal directly with action objects at 
all.

Another proposal which would solve the problem of potentially encapsulating too 
much would be to add a view for a logs.html that shows very single query with 
pagination for the query set. This way the users who really want to see all the 
details of all of the logs, have a way to do it  (without having to make query 
to logEntry on their end) and the recent actions will have a lot cleaner look. 

I’m sure there are little details that can always be improved in every 
solution. I would really appreciate your inputs on the same

Adam: Let me know if this seems like a remotely satisfactory solutions or if 
there are other problems I should consider.

If this seems like a helpful proposal I would like to take this entire segment 
up for my GSoC Proposal in 2021.

Regards
Muskan Vaswan

> On Dec 16, 2020, at 7:41 AM, Akshat Sharma <akshatsharma5...@gmail.com> wrote:
> 
> Hi
> 
> Well I am an webdevloper and pretty new to the django so
> 
> but If the issue is only to make log more efficient and useful then we can 
> implement javascript into the admin site
> 
> it can be resolved with pretty simple js and can be directly implemented into 
> HTML and can be a major advantage in scaling up
> 
> On Wed, Dec 16, 2020, 05:26 Carles Pina i Estany <car...@pina.cat 
> <mailto:car...@pina.cat>> wrote:
> 
> Hi,
> 
> On Dec/16/2020, Muskan Vaswan wrote:
> 
> > LogEntry which are used in the templates already. Note that this is the
> > most basic draft just to give an idea of what I’m trying to say. About
> > having 1000 rows, we will have to reach a consensus to put an upper limit
> > to the number of rows that can be encapsulated into one. I would suggest
> 
> If this was done it would be nice to see something like:
> "Deleted 15 items"
> "Deleted 515 items"
> "Deleted more than 1000 items" (if it deleted more than 1000 if 1000 is
> the upper limit)
> 
> So it's informative, correct and should not be a database killer. I
> haven't checked recently the datamodel but to avoid the COUNT I think
> that it can be done with a query, slicing it to limit+1 (to force a
> LIMIT in the SQL) and if there are limit+1 elements then say "Deleted
> more than..." or probably some other way that I haven't thought now :-)
> 
> Cheers,
> 
> -- 
> Carles Pina i Estany
> https://carles.pina.cat <https://carles.pina.cat/>
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com 
> <mailto:django-developers%2bunsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/20201215235540.GE32607%40pina.cat
>  
> <https://groups.google.com/d/msgid/django-developers/20201215235540.GE32607%40pina.cat>.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com 
> <mailto:django-developers+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/CABt%3Dxpqb%2BPj8u%3D7vCNQDXoHe_6%2B4WbyExX0pwFdtVQjT0EEoXw%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/django-developers/CABt%3Dxpqb%2BPj8u%3D7vCNQDXoHe_6%2B4WbyExX0pwFdtVQjT0EEoXw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/6C676109-3DB8-4A92-AC95-2570633C2029%40gmail.com.

Reply via email to