0

Displaying problem with views. I am trying to make a ranking for my track club.

Every result by someone is a node. I can make a global ranking with views showing all results sorted by running time (lowest time is first item).

Ranking total view looks like.

name    - time  - place
runner1 - 12.00 - city1
runner2 - 12.01 - city1
runner3 - 12.10 - city1
runner1 - 12.15 - city2  
runner1 - 12.20 - city1
runner3 - 12.25 - city5
runner4-  12.40 - city1

I need a ranking system with only the best performances. Curently a have used VIEWS AGGREGATOR PLUS (view first item on name) to help me filter some nodes. So my bad 'best results view' looks like:

name    - time  - place
runner1 - 12.00 - city1
runner2 - 12.01 - city1
runner3 - 12.10 - city1
runner1 - 12.15 - city2  
runner3 - 12.25 - city5
runner4-  12.40 - city1

I can't seem to only select the node with the best perfomance if there is another node from the same runners result in another city.

My ranking should look like:

 name    - time  - place
 runner1 - 12.00 - city1
 runner2 - 12.01 - city1
 runner3 - 12.10 - city1
 runner4-  12.40 - city1

So my views should : Select node where 'time' is lowest per 'name'.

How can I do this?

1

Views is a simple query builder. It is good at building 1 query, or many simple queries. There are times when relying solely on Views, and the assumption that your logic and be easily tailored to Views may fail.

This is such an example where it would benefit you to do some of this work outside of Views itself and store and compute metdata on to more easily generate reports.

For example you could install Nodequeue, Views Bulk Operations and Rules to perform the following tasks:

  1. create a nodequeue for city_fastest_times_results. Create 1 nodequeue per city.
  2. Write a Rule that upon saving of a track time examines if it is the fastest time yet recorded for that city. If so, insert it into the appropriate nodequeue.
  3. Using VBO to reuse the rule you defined in 2 to run this processing on any previously entered data on the website.

note: a SmartQueue may be able to allow you to encode this logic as well, as opposed to Rules.

Instead of Nodequeue you could also use the Relation module to relate cities, runners and times.

So, the nodequeues can store the fastest times per city and self-update based on Rule logic, or occassionaly by an admin using a VBO form. To show a report you would then just have SELECT * FROM {nodequeue_N} ORDER BY time DESC, which is trivial using Views.

0
0

Got it working to my liking(for now)

module:Views Aggregator Plus views display as:Table with aggregation options group and compress (name)

Now display only 1 name and best result in views table

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.