• Resolved Driekes

    (@driekes)


    I am trying to build a tool that allows our cyclist member to register to a cycling event.
    Basically:
    – We have an event every Sunday
    – We have a list of predefined routes
    – We have a list of our members.
    – We ride in three groups

    Each week we would like to register who has ridden in which group and what route they have ridden that week.
    I would like to get an idea of:
    – How many and which people participated on each day
    – How many times a person participated.

    I have now set it up with three pods:
    – Routes (with distance and three relationships to events))
    – Members (with three relationships to events)
    – Events (with title and relationships to routes and members)

    On each event I can select three routes and choose participants three times. All are relationship fields. This setup works well if I do it for one group, but as soon as I add multiple groups (so basically have three routes/members connected to events), it becomes impossible to retrieve the data.

    E.g. for a member Ruud I would like to get:
    Event X, participated in group A who did route S with a distance of 50km
    Event Z, participated in group B who did route T with a distance of 55km

    This works well as long as there is one group and a single relation, but it becomes problematic to distinguish which rider was in which group, and which route they did.

    I find it very difficult to explain better, hope this makes sense.

    Should I rethink my setup?

    Alternative thoughts:
    On each pod ‘events’ it would be great if I could list all members and allow to add a checkbox ‘Group A, B or C’, but I couldn’t find a setup that matched this.

    • This topic was modified 6 years, 5 months ago by Driekes.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @driekes

    I think I understand your issue. Since you have 3 routes per event it’s difficult to link members to a specific route.
    In this case I think it would be better to create a separate sub-pod for Events named (for example) “Groups”.

    So you would have this:
    – Event
    -> Groups (multiple)
    -> Route (single)
    -> Members (multiple)

    Another option is to create more fields instead of a separate “link” Pod:
    – Event
    -> Group 1 Route (single)
    -> Group 1 Members (multiple)
    -> Group 2 Route (single)
    -> Group 2 Members (multiple)
    -> Group 3 Route (single)
    -> Group 3 Members (multiple)

    Hope this helps!
    Cheers, Jory

    Thread Starter Driekes

    (@driekes)

    Thanks for the quick reply. I exactly dit both the proposed approaches. Where I ended with both:

    1. Groups:
    The problem I had is that the data entry is three times the work, plus, on each day there is also a driver joining, which I would like to register as well. Alternatively I would like to create an overview on each rider with their riding history, sorted by date, then shown by group / route / distance. This I couldn’t achieve with the [if] statements in pods templates.

    So that I why I proceeded to point two.
    2. Single event
    Problem is that I want to show a total on a page, for all members by the quantity of routes they have ridden, but preferably also show the ride total.
    I have done that by a custom SQL query, but I didn’t manage to combine this for all three routes in the end. So then I decided to ask a question here.

    $params = array( 
    	'groupby' => 't.ID',     
    	'select' => 't.ID,
    	t.post_title, 
    	rides_groupA.ride_date.meta_value, 
    	COUNT(rides_groupA.route_groupA.distance.meta_value) as count, 
    	ROUND(SUM(rides_groupA.route_groupA.distance.meta_value), 0) as distance',
    	'where' => 'YEAR(rides_groupA.ride_date.meta_value) = "' . $selectedyear . ' " ',
    	'orderby' => 'distance DESC',
    	'limit' => $limit
    );

    So in this statement I’m coming from the ‘Members’ pod, I reference the ride program through the group link, then I get the distance of the related route. That works well.

    However If I simultaneously use:

    	COUNT(rides_groupB.route_groupB.distance.meta_value) as count, 
    	ROUND(SUM(rides_groupB.route_groupB.distance.meta_value), 0) as distance',

    It doesn’t work, it says ‘Unknown Column’.
    If I use it separately, it works. Alternatively, can I use three pods in one PHP page and combine that data later on?

    PS: My programming language is limited, so I’m just doing A LOT of trail and error 🙂

    Thread Starter Driekes

    (@driekes)

    Plus, I also see this when going into the template area and setting up the template. When I select the ‘members’ POD Reference on the right, I only see all the references for one of the ‘rides_group*’.

    E.g. I see rides_groupA, but rides_groupB + rides_groupB.ID etc.

    • This reply was modified 6 years, 5 months ago by Driekes.
    Thread Starter Driekes

    (@driekes)

    I test the array with Group A, it works, tested it seperately with group B, it works as well.
    Then I tried to combine, as written above, it doesn’t work. So I thought, let’s put it in the code twice and write the results to my own custom array. However that does give mixed results!

    It does correctly list people that have ridden in Group B, so the ‘where’ clause seems to be working, but then the ride count and distance count is still wrong.

    If I comment out the Group A part the Group B part runs properly, so I would assume something like caching? I have no idea or knowledge about the inner workings of this. Thanks for helping me out!

    • This reply was modified 6 years, 5 months ago by Driekes.
    Thread Starter Driekes

    (@driekes)

    @keraweb do you have a chance to check my question?

    Thread Starter Driekes

    (@driekes)

    @keraweb Sorry to bother you, but have you had a chance to check out my latest findings?

    Plugin Author Jory Hogeveen

    (@keraweb)

    The problem I had is that the data entry is three times the work

    I understand, but it’s important that your data entry is correct and not hanging on error sensitive code.
    Complex relationships like this require a correct setup to work properly.

    This seems a bit of an X/Y situation: http://meta.stackoverflow.com/questions/66377/what-is-the-xy-problem
    In your current setup you’d need field groups and that isn’t built into Pods core (yet). I doubt SQL keys like rides_groupB.route_groupB.distance.meta_value are supported by Pods at all.

    Before continuing trial and error, take a step back and make an overview of your setup so you can plan your actual code/relationships first. If you’d like my review on that, feel free to share it here!

    Plugin Contributor Jim True

    (@jimtrue)

    Closing this ticket as the original poster has not replied in over 3 weeks and the last response is pretty much on point.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Best setup’ is closed to new replies.