Saturday 23 February 2013

Order by on StatDiary


I've got a feature request last night. It was about the order of statistics. I was thinking if it would be an easy feature to implement.
Statistics are listed on two places. In the iPhone application and on the main logged in page on the website. Because of the custom data to load the iPhone list using a custom query - and the website is a simple Views list.

I think the best experience would be a drag and drop functionality on the website - or a drag-able table view in the mobile app. Updating the application is definitely not the way to go - and anyways, drag and dropping can be a pain sometimes.

I didn't want to add either a weight-based table to the website. Would be funny to make a new page just to serve that one thing. Not much left, it has to be a simple field on the node edit page - where users can add their 'weight' value. Simple and still works fine.

I guess it was pretty easy - adding the new field and the join to the query with the new order field. However MySQL prioritize fields where values are existing - that means if the order value is missing on an item it will be the first - being nothing < -infinite. That can be handled by using default values in the order: .. ORDER BY COALESCE(field_order_value, 0) ASC ..

It worked fine. The user who wanted to order the stats were happy. Case closed.

On the same moment I realized that core and some contribs were out of date - did a quick update and managed to break the site. All the Display Suite fields were broken. I started panicking - when found out that the update contained some functionalities decoupled in several DS modules, and I only had to enable them. Whew.

---

Peter

No comments:

Post a Comment

Note: only a member of this blog may post a comment.