I have 100+ points of data for a node type and want to work out average, high, low data points and put them next to each data field on that node type using computed field

Created on 29 April 2023, almost 2 years ago
Updated 2 May 2023, almost 2 years ago

So i have hundreds of nodes which are running races and each one has almost 100 data points.

Biggest elevation climb
Biggest climb length
Race distance
Race total elevation
so on and so on

I want to use php to find the averages, or low or highest data point from all of these nodes and place next to the fields on each and every node so that context can be given.

Like this, with computed field in brackets:

Race distance: 56km (72km average race length)

and do that for each and every data point on the nodes.

I've been playing around for a couple of hours, looked at some tutorials and have no idea still how to make this happen. I saw no place to put PHP to get this to work.

Any help would be good.

💬 Support request
Status

Active

Version

4.0

Component

Documentation

Created by

🇬🇧United Kingdom effortDee

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @effortDee
  • 🇬🇧United Kingdom joachim

    The PHP code goes into a plugin class.

    See the examples in the module code and in the tests in particular.

  • 🇬🇧United Kingdom joachim

    The clever thing would be to use the same one plugin class for ALL the averages. But you'd need a way for it to know which field it's taking its data from.

    The quick way would be to call each computed field a name that derives from the data source field, e.g. field_distance / field_distance_average. Then the plugin class removes the suffix '_average' from the name of the field it's computing, and uses that to run the average query.

Production build 0.71.5 2024