Integrate workout data from Garmin Connect into Drupal.
This project uses the Garmin Connect REST API to download your workout data from Garmin Connect and provides mechanisms for rendering and comparing workout data.
Data summary and presentation functions are provided:
- A block that lists your last X key workouts
- A block that rewards you for completing workouts that you hate
- A "quick view" of pace, heart rate, power, and other workout metrics
- A calendar-type view that summarizes this month's and last month's workout activity
You can use the Garmin Connector 'Compare Workouts' page to create lists of key workouts, ready to show to your coach or training partners. You can create sets of these workouts to make comparing key workouts easier.
Important notes:
- Although sample data is provided, you really need an account with Garmin Connect for best results. The current version of this software allows only one Garmin Connect user per drupal instance but plans are in place to extend this to multi-Garmin Connect users.
- No other project successfully interfaces with Garmin Connect in a complete way.
-
I heavily used this code when training for Ironman Coeur D'Alene 2013 and Ironman Lake Placid 2013. You can see different demos on Ironman training website ironman.teamchad.ca. You can start by checking out the project demo page there
Important Links
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/candotri/1816816.git garmin_connectorReviews of other projects
- https://drupal.org/comment/8159449#comment-8159449
- https://drupal.org/node/1973014#comment-8159461
- https://drupal.org/comment/8159483#comment-8159483
- https://drupal.org/comment/8159511#comment-8159511
- https://drupal.org/comment/8217533#comment-8217533
- https://drupal.org/comment/8230459#comment-8230459
- https://drupal.org/comment/8230473#comment-8230473
- https://drupal.org/comment/8230491#comment-8230491
- https://drupal.org/comment/8230499#comment-8230499
- https://drupal.org/node/2154923#comment-8308977
- https://drupal.org/comment/8308997#comment-8308997
Comments
Comment #1
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://ventral.org/pareview/httpgitdrupalorgsandboxcandotri1816816git
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #2
candotri commentedI attended to many of the issues described in the automated review process. I consider the review complete.
Comment #3
PA robot commentedClosing due to lack of activity. Feel free to reopen if you are still working on this application.
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #4
candotri commentedComment #5
klausiThis is not fixed? See https://drupal.org/node/532400
Comment #6
sreynen commentedhttp://pareview.sh/pareview/httpgitdrupalorgsandboxcandotri1816816git still shows thousands of code formatting errors. None of those are individually blockers, but there's so many that it's going to be difficult for anyone to read the code to review.
Much of that is likely due to the 3rd party libraries you have included directly in your module. Those need to be changed to a library include to prevent errors with other modules using the same libraries. See: https://drupal.org/node/422996
Comment #7
ygerasimov commentedMore points to improve:
- use 7.x-1.x branch instead of master
- remove all dpm() (found them in .install file)
Comment #8
candotri commentedCompliance with the style robot complete. I'll work on using the flot library in a different way. Is there anything that can be done while I'm working on that?
Comment #9
candotri commentedAnyone?
Comment #10
klausiYou need to set the status to "needs review" if you are ready and want to get a review, see https://drupal.org/node/532400
Comment #11
candotri commentedThanks, @klausi. Oops.
Comment #12
candotri commentedOK, I did a bunch of work to suppress unused variable errors. All that's left are errors because I use vim modelines
I get "3526 | WARNING | There must be no blank line following an inline comment" when the last line of the file is this:
3526 // vim: syntax=php ts=2
Is there an appropriate way to suppress that?
Comment #13
kscheirerYou could abstract that out from all 3 code blocks and just put it at the bottom of the function.
That's as far as I've gotten, this is not a complete review. The module seems very ambitious and potentially useful, but right now there are a lot of unfinished parts and debug code.
My suggestion is to limit the scope down to what's absolutely necessary (or what you actually have time to build), and delete everything else for now. You can always add it back in later :) Otherwise you'll never get out of "needs work" if there are unfinished bits hanging around.
Let's work on getting this approved, and then you can add new features in the next version.
----
Top Shelf Modules - Crafted, Curated, Contributed.
Comment #14
candotri commented@kscheirer Thank you so much for clearly spending a lot of time twlling me what I need to do. I'll get on this and report back.
I have a couple of questions:
1. Regarding deleting dpms that are commented out: Is this an asthetic thing? Clearly there is no functional penalty for commenting out code. Given the complexity of some of the things I have to do it would be super irritating if, at a later date, Garmin changes something (very common) and I have to figure out how to debug the code.
2. garmin_connector_update_7002 was for me. I have had people check code out of the git to help me debug and that's why that update is there. Is there any harm in leaving it there?
3. removed stuff from .info
4. removed stuff from .install
5. Regarding varchar(40) for user, no I don't want to use uid. It's an experimental feature that I'm working on. I could delete it but I want to work on it moving forward.
6. The Makefile and the testing stuff was me trying to learn to use the Drupal testing framework and to automate some drush commands for maintaining databases with hook_cron. I'll remove them but I'd like to eventually make it work.
6. regarding hook_init: I can't persuade Libraries to load the javascript for flot. It is, apparently, a 'feature' in Drupal's flot. I tried really really hard. Really I did.
7. Added flot to dependencies
8. Removed ini calls. Silly question: What is bare php?
9. hook_block_view, did what you suggested. It was, of course, a better way.
10. Regarding $_garmin_connector_cf: There were so many things that I needed to keep track of. I could remove the global and call a method to return a key. Is this, in your view, cleaner or are you concerned about the global variable. I'm going to assume that the method call is just cleaner:
11. Deleted descriptions array. You are quite right.
I just committed the things I described and I'll go through the code looking for dpm()s. The issue I'm having at the moment is that I made *so* many changes to make things comply with pareview that I feel I need to test things thorough to make sure that things still work. For that I'll need the dpms. I'll work on that testing as quick as I can and then remove whatever I can.
Thank you again for your review.
Comment #15
candotri commentedDid the following things:
I also did a lot of general cleanup. There are still dpm()s while I debug performance given the large amount of rennovating I've been doing.
Comment #16
candotri commentedChanged hook_menu to add the path 'garmin-connector/' where I've added pages. Testing functionality and repairing where necessary.
Comment #17
candotri commentedI added a demo page to showcase what the components do. Everything is working correctly.
Comment #18
kscheirerAre you ready for another review?
Comment #19
candotri commentedYes, please.
Comment #20
kscheirerSorry, I didn't see that list of questions!
Yes, just aesthetic. If you feel strongly about it it's fine to leave them in.
It's ok to leave that in, just not usual for a new module.
It's PHP code that's not contained in any function, hence "bare". When Drupal loads your file as part of it's normal process, any bare PHP is always executed - so it's on every page request, regardless of whether it's useful or not. Can be bad for performance, and just a general bad practice.
We try and avoid globals wherever possible. Generally you can get the same functionality with variable_get/set (for permanent storage) or drupal_static (for storage throughout a single request).
Comment #21
kscheirer$days = variable_get('garmin_connector_reward_number_of_days') ? variable_get('garmin_connector_reward_number_of_days') : 7;use$days = variable_get('garmin_connector_reward_number_of_days', 7)if (is_array($key)) {}), change your foreach toforeach ($workouts as $workout) {. No $key variable needed :)<h2>Did you complete the workouts you hate?</h2>use'<h2>' . t('Did you complete the workouts you hate?') . '</h2>'This is another partial review.
candotri, I think you have the same problem of having too much debug/test code to get this project approved. I think what's happening (as you mentioned earlier) is that you're still in the debugging process of your module, and it's not polished yet. It's understandable that you still want debug code, and it's fine in a sandbox as well, but for a Drupal module, users expect to download a working, finished module. That's not to say it has to be bug-free, but the basics have to be covered.
I think the best solution is for you to create a local branch to work from (
git checkout -b 7.x-1.x-debugor something). Don't push it to origin, just keep it local (if you do accidentally push it, no big deal). You can keep your debug code in there for checking stuff out, and the main 7.x-1.x branch to keep the finished code. Then keep the 7.x-1.x branch clean and tidy. You can usegit mergeto easily move changes from one branch to another. This is a good simple guide to git if you're not used to it: http://rogerdudler.github.io/git-guide/.Or you could make the debug stuff "official". What I mean by that is, create a hook_menu entry for it, put permissions around it, render the output like you would any other Drupal function, and move the code out of your .module file. Some modules provide test pages like this, like a page where you can test that your garmin connection is working, or that it's parsing a dummy data file correctly.
From #13:
Instead of deleting, you can keep that code in a different branch.
Also, take a look at Tips for ensuring a smooth review - that covers a lot of common things we look for when reviewing a module.
Hope that helps!
----
Top Shelf Modules - Crafted, Curated, Contributed.
Comment #22
candotri commentedI hear what you are saying about the debugging. The thing is, I trust the code. But I don't particularly trust Garmin. That's the problem with interoperability without accountability - they can change anything at anytime.
I've removed almost all of the debugging code that prints to the screen. I've left the debugging code that prints to files. I feel that this way anybody who wants to know what's going on will know and those that are not able to help won't be bothered by weird output.
I use this code every day for things that matter to me so I feel that it's reliable and useful.
I hope you agree that this would be useful to other people. I certainly don't see code like this out in the wild.
Regarding specific issues:
I'd like to note that debug code is still present in the code that calls garmin. I feel that this will be necessary moving forward.
Thanks for the patience.
Comment #23
candotri commentedHere's another reason why I'm leaving a bit of debugging code in. From my last commit:
4 files changed, 250 insertions(+), 480 deletions(-)As the review progresses, the code is getting leaner and meaner but I'm continually testing that it still works.
Comment #24
candotri commentedComment #25
candotri commentedComment #25.0
candotri commentedadded link to project page
Comment #26
kscheirerCandotri, this queue is for use to review finished, working modules to grant you the 'git vetted user' status. Unfortunately, it's not intended to help you learn coding best practices. Additional workload for reviewers results in longer wait times for everyone in the queue. I'm setting this issue to postponed, please feel free to reopen it when you think it's ready for review again.
Take a look at Tips for ensuring a smooth review for a list of common issues if you haven't already.
Comment #27
kscheirerComment #28
candotri commentedTo the best of my knowledge I do not require further assistance in learning coding best practices.
This is a finished, working module that meets standards described here:
https://drupal.org/node/1187664
This module is ready for review.
If there are specific requirements that I am not meeting, please let me know and I will meet them immediately.
Comment #29
heddn@candotri, What are you trying to do with flot that you can't use the flot module? I've used it fairly extensively and never had problems with its loading using libraries.
Comment #30
klausiThere is still a master branch, make sure to set the correct default branch: http://drupal.org/node/1659588 . Then remove the master branch, see also step 6 and 7 in http://drupal.org/node/1127732
Review of the 7.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
I agree with kscheirer that a full project should be production-ready and not contain site-breaking debug code. If you must do that do it in a debugging git branch or add a conditional debug mode.
manual review:
Comment #31
candotri commented@heddn I repaired the issue. Thanks for the comment.
Comment #32
candotri commented@klausi Thank you for your time!
I'm not sure if you've seen the number and volume of commits that I'm putting into this project in order to comply with the comments. I think that they speak to the amount of work that I'm doing. I appreciate the fact that we are trying to build a solid code base and I appreciate your time.
I will now go and try to get review bonus points.
Comment #33
candotri commentedComment #34
candotri commentedComment #35
candotri commentedComment #36
candotri commentedComment #37
candotri commentedComment #38
candotri commentedComment #39
candotri commentedComment #40
candotri commentedBroke something while repairing sorting. Will update when ready.
Comment #41
candotri commentedComment #42
candotri commentedComment #43
candotri commentedThis module is complete and ready for review.
I test this module two ways:
The automated site operates using php5.3 and the existing site uses php5.4.
I suggest you download the sample data something like this:
sudo -u www-data drush -r $DRUPAL_ROOT garmin-connector-sample-dataObviously that this assumes LAMP and the apache user www-data. It's ok to not sudo but remember to change permissions when required.
Comment #44
candotri commentedComment #45
candotri commentedRepaired broken link. Updated with git checkout command.
Comment #46
candotri commentedAdded project review.
Comment #47
klausimanual review:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #48
candotri commentedThank you for the comments @klausi,
Notes about my feelings on permissions:
I'm unsatisfied with the generic "Permission Denied" errors when one uses access callbacks in hook_menu. I prefer to check access in the page callback and when permission is denied, provide the user with the *reason* permission is denied. Is there a best practice somewhere that recommends against this? The only risk that I can see is in the case of a DOS attack on that page there is a small amount of overhead in activating the callback.
Comment #49
candotri commentedAdded review.
Comment #50
candotri commentedAdded a review.
Comment #51
candotri commentedAdded a review.
Comment #52
candotri commentedAdded a review
Comment #53
candotri commentedComment #54
klausiThe usual Drupal philosophy is to not display any links to pages where the user does not have access to in the first place. Also that pages should not leak any information what is behind them, so anyone that does not have access should just get a generic 403.
manual review:
'#markup' => "<h3>Workout set with name $set</h3>",: all user facing text should run through t() for translation.So the potential XSS issue is a blocker right now, otherwise this looks quite ok.
Comment #55
candotri commentedComment #56
klausimanual review:
t("Workout set with name") . " $set</h3>": do not concatenate variables into translatable strings, use placeholders with t() instead.The use of check_plain() is a blocker right now, you need to know when to use it and when not. Otherwise this would get a green light from me, so don't give up just yet, I think you are almost there!
Comment #57
candotri commentedThank you for your time, @klausi !!
I did additional review looking for untranslated strings and as far as I can tell the check_plain usage is legitimate.
I sincerely appreciate your time. I will continue to review projects to help you and the community.
Comment #58
candotri commentedAdded review
https://drupal.org/node/2154923#comment-8308977
Comment #59
candotri commentedAdded review https://drupal.org/comment/8308997#comment-8308997
Comment #60
klausimanual review:
"<p>" . t("Purging") . $location . ":" . "$status</p>";: do not concatenate variables into translatable strings, use placeholders with t() instead.Bu otherwise I think this should be now sufficient, so RTBC from me.
Assigning to kscheirer as he might have time to take a final look at this.
Comment #61
candotri commentedThank you for your time @klausi . I worked hard to help by reviewing other projects.
Comment #62
kscheirerWhat is the latex directory for? Is it something that the user needs to install? I don't see anything about it in the README or hook_requirements().
Comment #63
candotri commentedSorry about the latex directory. Removed the latex directory and other unused files including debug-tcx.tcx, tcx.tcx, logtail.js, and logtail.html
Comment #64
klausiCool, back to RTBC.
Comment #65
klausino other objections for more than a week, so ...
Thanks for your contribution, candotri!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #67
avpaderno