Duration Module not compatible with Views Calc

kmonty - February 27, 2009 - 21:29
Project:Duration
Version:6.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

I am setting up a athletic training log and finding Duration to be the ideal CCK extension to allow people to enter in the duration of a days activity. I was hoping to use Views Calc to display the SUM and Average of the the daily duration for a specified period of time, however, the Views Calc method cannot sum ISO 8601. I created a custom display that converted the H:i data to be a decimal (read: 2hrs 30mins -> 2.50) but quickly realized that Views Calc sums the values from the database, not the output.

Can anyone think of any potential solutions?

#1

jpetso - February 27, 2009 - 22:00
Category:feature request» support request

Background to ISO 8601 in a nutshell: One cannot know the exact duration of "1 month" without knowing the start or end date of the duration. ISO 8601 captures that information correctly even if the start or end date is not known. The downside of that additional flexibility is that performing calculations on ISO 8601 values requires code that knows how to handle dates and durations. (Which is mainly why there is a Duration API.)

However, the Duration field also stores the approximate duration ("what we can guess without knowing the start or end date") in a cached field named "approx_seconds". If you don't use months or years then this field is still accurate, so you can tell Views Calc to calculate on that field instead of the "iso8601" one.

#2

jpetso - February 27, 2009 - 22:02
Status:active» postponed (maintainer needs more info)

Oh right, issue status. I'm setting this to "active (needs more info)", please close it as fixed if the approx_seconds column solves the issue. Otherwise, please explain what doesn't work out still.

#3

kmonty - February 27, 2009 - 22:59
Status:postponed (maintainer needs more info)» active

Currently, as far as I can tell, there is no way to access the approx_second database column through views, which is basically the problem. Views Calc works by doing math on the database columns defined in a view's fields. Unless I am completely missing something, there is not a way to get the approx_seconds as a field. Even so, that would only sum the seconds (which would at least be useful because I could easily convert that to hours/minutes using php in preprocessing.)

Maybe a solution is to create a second selectable field that accesses approx_second in addition to ISO 8601?

#4

bfr - July 7, 2009 - 14:38

Did anyone solve this?

#5

appel - July 10, 2009 - 10:37

Subscribing.

#6

bnicoll - September 20, 2009 - 13:26

Trying to do the same thing. Want to do calculations based on a users time spent completing a particular activity. Hours, Minutes, Seconds only.

#7

jpetso - September 21, 2009 - 07:08
Category:support request» feature request

Needs an implementation of 'views data' for hook_field_info(). Some other CCK modules have similar implementations, so the best bet is probably finding a CCK field module that provides two kinds of field data for Views, and copying/adapting the respective code.

Unless you're massively lucky though, I probably won't spend time implementing this feature. Which means for you: talk is bronze, code is gold.

#8

pragnatek - October 14, 2009 - 10:29

subscribing

 
 

Drupal is a registered trademark of Dries Buytaert.