Sorting and filtering events
Fri 12th November 2004 14:25 EET
The other day, I was wondering how could a simple event listing take so long and how could it work so oddly? After some paper-aided code tracking I found out that it took four mgd_get_article() calls for a single event to display. This notion led me to write new filtering and sorting code for de.linkm.events.
The previous system was working as follows:
- Get all article IDs into an array
- Sort the ID array
- Filter the sorted ID array based on MidCOM field filters (optional)
- Filter the sorted, filtered ID array based on time intervals (event end date) li>
Obviously, every single step did mgd_get_article() and returned just the array with IDs. The first thing was to make filtering/sorting work with object array to cut down the unnecessary mgd_gets. Other thing was to rethink the order of all filtering and sorting. Here's the new process:
- Get all article objects into an array
- Filter the object array based on time intervals (event end and start dates)
- Filter the time filtered object array based on MidCOM field filters (optional)
- Sort the filtered array
I don't have any scientific data on the enhanced speed of the process but based on some rational thinking, and a gut-feeling, I can say the filtering is much faster (and better) now. The same renovation should be done to some other components too - at least de.linkm.newsticker and net.nemein.simpledb are on my list.
