PeterDK Posted February 18, 2014 Share Posted February 18, 2014 Hi, I have about 2000 pages with the following fields: rider distance number of rides year There is only one entry per rider and per year. The data looks like this: Peter - 700km - 10 rides - 2013 Bill - 600km - 8 rides - 2013 Peter - 700km - 10 rides - 2012 Bill - 800km - 11 rides - 2012 ... This continues for 41 years and 300 riders. My yearly overview is doable with a simple 'selector'. > select all riders with year 2013 sorted by distance PW comes back with 53 riders, I easely loop over the results (and while doing that calculating the totals) I would like to have a 'report' with the riders of this year (2013) with all their rides ever done. > select all riders of 2013 > select all their rides all previous years > sum their disctances and sort How should i apprauch this: Should I use sql queries myself? Is there a 'sum' function, much like the current 'count' that doens't reall have to get all these pages during calculation. Secondly, these reports are really static until 'some things' changes. I don't have a lot of visitors, what would the best cache option be for this situation? Peter Link to comment Share on other sites More sharing options...
horst Posted February 18, 2014 Share Posted February 18, 2014 Secondly, these reports are really static until 'some things' changes. I don't have a lot of visitors, what would the best cache option be for this situation? I would use ProCache. It is highly configurable and lightning fast. In fact it serves static html pages. No DB and no PHP-interpreter are involved in serving this pages. Link to comment Share on other sites More sharing options...
kongondo Posted February 18, 2014 Share Posted February 18, 2014 (edited) How should i apprauch this: Should I use sql queries myself? Is there a 'sum' function, much like the current 'count' that doens't reall have to get all these pages during calculation. I don't think there is a sum function in PW...PHP can do that .....One approach is to use a hidden field that does the calculations for each rider behind the scenes on each page save. See this thread (especially Ryan's post) for an explanation http://processwire.com/talk/topic/5441-kind-of-calculated-field/. The advantage here is that no calculations are done on the fly on each web request...The sums are there to cherry pick from the DB... Edit: I've just realised Ryan's answer was in response to a similar (well actually the same) question that you Peter asked! Did you even read that thread? Edited February 18, 2014 by kongondo 2 Link to comment Share on other sites More sharing options...
Soma Posted February 18, 2014 Share Posted February 18, 2014 You know we get older. Sometimes I find myself asking "hey was that me?" 5 Link to comment Share on other sites More sharing options...
kongondo Posted February 18, 2014 Share Posted February 18, 2014 You know we get older. Sometimes I find myself asking "hey was that me?" Haha. Been there, done that. Searching via Google does that a lot to me... 1 Link to comment Share on other sites More sharing options...
Joss Posted February 18, 2014 Share Posted February 18, 2014 Haha. Been there, done that. Searching via Google does that a lot to me... I had to search on Google today for something relating to a client and I still came back with me! Damn ... that is so unfair! Separately and aside from that and in answer to the OP - yes, all of that can be done with PW one way or another, but I warn you, there maybe more than one way you can do it! I suspect you will need to use a bit of php to do the adding up, but that is what it is there for, really. Link to comment Share on other sites More sharing options...
Wanze Posted February 18, 2014 Share Posted February 18, 2014 How should i apprauch this: Should I use sql queries myself? Is there a 'sum' function, much like the current 'count' that doens't reall have to get all these pages during calculation. Depends on your knowledge. The Database design of ProcessWire is pretty easy, so if you know MySQL you should be fine. Another possibility is to build your reports only in small steps, e.g. with fixing the limit selector and increasing the start selector. This way you only query a subset of the data which you sum up or cache. Secondly, these reports are really static until 'some things' changes. I don't have a lot of visitors, what would the best cache option be for this situation? Creating reports from data is usually done separately e.g. you could copy your database and generate your reports from the copy. This ensures that you don't have any performance issues for the regular website users. But maybe this is not necessary. Still I would generate the reports maybe with a command line script. If you need to create them regularly, you could also use a cronjob for this Link to comment Share on other sites More sharing options...
PeterDK Posted February 18, 2014 Author Share Posted February 18, 2014 Guys, I'm reading all your inputs like crazy, so thank you very much. Now thinking what approach to do ;-) THANKS! Link to comment Share on other sites More sharing options...
Joss Posted February 18, 2014 Share Posted February 18, 2014 Take a tip from the PW tutorial I am currently writing: Make a coffee, get a huge piece of paper, a pencil and an eraser, lie on the floor and get planning. You will get your approach worked out ten times as fast as you will on some new-fangled computer gizmo! 5 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now