ElkArte Community

Elk Development => Feature Discussion => Topic started by: emanuele on October 08, 2013, 11:39:38 am

Title: The queries countdown
Post by: emanuele on October 08, 2013, 11:39:38 am
One of the "goals" is to move all the queries out of the controllers, well let's see after one year of work where we are.

I did a simple search of the code using $db->query, finding:
/controllers/ => 137
/admin/ => 96

Well, to be honest I hoped/had the feeling we were in a "better shape", though it's not that bad and we can (and should) improve. :P

To do a comparison with what we started in SMF I searched (excluding all the "Subs-*" and "db" files) $smcFunc['db_query, finding 1104 instances.
Title: Re: The queries countdown
Post by: Spuds on October 09, 2013, 12:08:22 pm
Well 1104 down to 233 is a pretty darn good start ... plus we MAY have added a query or two along they way :P

Agree we need to 'finish' the improvement job  :D
Title: Re: The queries countdown
Post by: emanuele on October 09, 2013, 01:17:09 pm
Quote from: Spuds – Well 1104 down to 233 is a pretty darn good start ... plus we MAY have added a query or two along they way :P
/me is innocent! :P
Actually is +14 because I didn't notice the $db_search->search_query, so 247. Still a good reduction. :D

Quote from: Spuds – Agree we need to 'finish' the improvement job  :D
Yep!

In the meantime, an update after merging a couple of branches:
/controllers/ => 142
/admin/ => 88

And a bit of additional analysis.
Regarding the /admin/ dir:
RepairBoards.php is the one accounting for the relative majority of the queries: 39. That file is scary TBH...do we really need all this? Can it be reworked to use functions we already have? What do you think?
The second file in terms of queries is ManageAttachments, this is as usual a bit tricky I think...
Special case (I think) AdminDebug.controller.php: it has both queries and markup. I'm not sure if it is a special case, since I suppose it should just adhere to the standards of the rest of the code...or not?

The /controllers/ dir, instead, is more "messy", there are still 5 files with more than 10 queries:
PersonalMessage (20)
Recent (17)
RemoveTopic (16)
ProfileHistory (15)
* ProfileInfo (15)
Title: Re: The queries countdown
Post by: Spuds on October 20, 2013, 11:35:59 am
Just made the pr for profile info, so knock 15 more off the list :)
Title: Re: The queries countdown
Post by: TE on October 21, 2013, 01:26:33 pm
Groups controller should be free of queries, too: PR is https://github.com/elkarte/Elkarte/pull/919 (https://github.com/elkarte/Elkarte/pull/919)

Title: Re: The queries countdown
Post by: TestMonkey on October 21, 2013, 06:53:20 pm
YAY!

OK, this is extremely refreshing for the codebase, and incomparable by a great length with SMF. And unbelievable, how fast you folks went through it.

@Trek,
How about you grumble at us meanies to give you details on this reasons -> progress -> achievement -> consequences, then please, help shape up our mumbling into a decent form.
For the mid-level development documentation (changes from SMF, Elk presentation, oriented dev-wise). We have similar github wiki pages already, they just want added to. ;)
Title: Re: The queries countdown
Post by: emanuele on October 22, 2013, 09:10:25 am
And update after the last merges:
/controllers/ => 122 (110+12)
/admin/ => 76 (74+2)
Grand total: 198

Under the 200! YAY!

Next goal is 100! ;D
Title: Re: The queries countdown
Post by: emanuele on November 01, 2013, 10:49:12 am
Another week and:
/controllers/ => 113 (101+12)
/admin/ => 17 (17+0)
Grand total: 130
Title: Re: The queries countdown
Post by: Spuds on December 16, 2013, 09:56:51 am
If I did the same search(s) I think its now

Controllers (75 / 12)
Admin (3 / 0)

Total of 90 !

but we need the master counter to verify  O:-)
Title: Re: The queries countdown
Post by: emanuele on December 17, 2013, 12:44:33 pm
(http://www.easymemes.com/uploads/memes/101329_aLKmwXwa1VXGEGh.jpg)

Spoiler (click to show/hide)
Title: Re: The queries countdown
Post by: Spuds on December 17, 2013, 02:40:34 pm
I look forward to the awesome sauce !
Title: Re: The queries countdown
Post by: emanuele on June 13, 2014, 04:51:52 pm
Final count for 1.0 is:
controllers: 68 / 12
admin: 1 / 0
Total: 81.
Very good situation considering where we started! :D

The development branch is already at:
controllers: 47 / 0
admin: 0 / 0
So, just 47 queries in total!
Thanks to
@groundup for his contributions to the task! :D (Or maybe it was at bringing back to controllers things that were not supposed to stay in subs... either way thanks. :P)
Title: Re: The queries countdown
Post by: Spuds on June 14, 2014, 08:18:48 am
Wow ... its all a blur now :P ... 1000+ knocked down to 81!  Awesome job everyone!

One other goal/objective in 1.1 would be to combine any duplicate/similar ones where it makes sense ... I know we have a few similar to one another in a few places,.  Just getting them out of the controllers was monumental task to start with, and I must say being able to use them in addons is a delight :D
Title: Re: The queries countdown
Post by: TE on June 15, 2014, 10:55:53 pm
oh, that's great :D