WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Runners Log] Running gear statistics (50 posts)

  1. TheRealEyeless
    Member
    Posted 4 years ago #

    Posting from frold, see original thread

    Further plans:
    One major plan is actually the one you mention: being able to track your gear and see for how many km/miles you have used your shoes etc.

    But for that I need a new way to put in data.
    I would like to be able to add and delete gear and have the gear eg sorted in different categories.

    Eg: using:
    http://dev.iceburg.net/jquery/tableEditor/demo.php
    with
    http://tablesorter.com/docs/#Demo

    But Im not sure if I have those skills...

  2. TheRealEyeless
    Member
    Posted 4 years ago #

    What do you want the new interface exactly for? Do you want to enter the whole data independently from the posts to be entered or just for entering nrew gear and being able to use them when entering a new post? Or should these listings just be some kind of statistic page in the background like the (amazing :)! ) calculators?

    In my opinion there should be a way to setup the available hardware once and select them in every posting for each run. Maybe in select-box or something. Afterwards it might be possible to select for the stats next to month, year also the used gear.

    Cheers Eyeless

  3. frold
    Member
    Posted 4 years ago #

    I dont know how to do this 100%

    If you have a normal text field - you need to spell the shoe or gear name 100% correct each time.

    The ultimate way of doing this is mix.
    1. a page where your control (add or edit) your gear and set a category
    2. the setup page where you enable or disable the gear feature
    3. in some way being able to combinate the gear list with the metabox. The metabox is this one:
    http://s.wordpress.org/extend/plugins/runners-log/screenshot-1.png
    There should be added a new field per gear category. If you have added 2 shoes 1 t-shirt - there should be 2 new fields:
    Shoe
    T-shirt
    The content in them should be choosen from a drop-down menu where you in the field "shoe" get your 2 shoes etc...

    I dont know if this is too advance - but it was my ultimate idea...

  4. frold
    Member
    Posted 4 years ago #

    Just for your information .- just found this one: http://www.mysqlajaxtableeditor.com/index.php seems pretty nasty :)

    I dont have the more time today, sry...

  5. TheRealEyeless
    Member
    Posted 4 years ago #

    ok, got your idea, drop-down in the metabox is exactly what I meant!

    I am not quite sure, whether I got your idea how to use the information correctly. Consider we have a mysql-ajax-tableeditor, what do we do with it? Should it just be used in the backend or also in the blogposts? And for what use case exactly?
    In my opinion the magic mysql-ajax-table is nice to have for editing running information but it has some tradeoffs:
    -what happens if a user edits the time of its runs? Are the blogpost afterwards still work correctly? (I currently don't know how a blogpost is mapped into your db)
    -how do we limit the number of new cols? Consider the case that a user creates tons of new colums for different kinds of running gear...wouldn't be the best for the performance if this table is queried often. I'd prefer some simple php commands in the backend.

    In my opinion the current questions are

    a) how to add new kind of gear and how many
    IMO it would be enough to just track shoe usage, but there should be no problem in having methods to add a unlimited nb of kinds of gear. If a new kind is added I would add a column to the DB for each run storing the information which example of this kind was used.

    b) how to add gear usage
    IMO there should be a menu in the backend to add and delete certain gears. And in the metabox should be a drop-down list for every kind added.

    c) what and how to visualize the usage
    - km run with each example of a gear ([gear_log "km" "shoes" "pie"])
    - percentage of usage per example per gear ([gear_log "percentage" "shoes" "bar"])

    what do you think ?

  6. frold
    Member
    Posted 4 years ago #

    That statistics is the smallest problem - as I see it :) A [runners_log_gear] tag should be easy to create.

    The problem is as you are mention - howto handle the information.

    The idea with the fancy table editor was to use in a special gear page in Admin. Here you should be able to set
    1. name eg: Nike
    2. type eg Trail
    3. category eg: Shoe
    4. Usage eg km/miles
    5. Date bought
    6. Last time used
    7. Number of time used
    (8. Adding a image of the gear) - not so important

    When you are adding a new course using the meta box you should be able to - in some way - choose what gear you have used based on your gear list.

    The gear list is created using the "fancy" editor or some other thing.

    Based on your courses and distances the "usage" field for the shoe or what ever is increased. Eg. you can set a manual start usages when you are adding the item.

    Does this make any sense or is there a better way to solve this?

  7. TheRealEyeless
    Member
    Posted 4 years ago #


  8. TheRealEyeless
    Member
    Posted 4 years ago #

    ok, consider we have a simple way for creating gears. It inserts information in a table GEARS with the columns (id|gear|name|buy-date) and per run can only be used one gear. Most you mentionded should be quite easy (I have a little problem to check my idea, since I currently don't find the used tables in you plugin in my db, but I will figure them out). Consider we have currently a table RUNS storing each run:
    (id|date|time|distance)
    and add gear-id, so we get:
    (id|date|time|distance|gear-id)

    This provides information about:
    1. name (names are stored in GEARS-table)
    2. type eg Trail (could be added to GEARS table but obvious since Name and type should provide this information(mine do it and but I've just three pairs of running shoes))
    3. category eg: Shoe (types are stored in GEARS-table)
    4. Usage eg km/miles (
    SELECT SUM(R.distance) FROM 'GEARS' AS G AND 'RUNS' AS R WHERE R.gear-id == G.id AND G.name =="Nike";)
    5. Date bought (date is stored in GEARS-table)
    6. Last time used (
    SELECT MAX(R.date) FROM 'GEARS' AS G AND 'RUNS' AS R WHERE R.gear-id == G.id AND G.name =="Nike";)
    7. Number of time used (
    SELECT COUNT(*) FROM 'GEARS' AS G AND 'RUNS' AS R WHERE R.gear-id == G.id AND G.name =="Nike";)

    And everytime you change something in the gears table you should get all available drop-down-items by SELECT names from RUNS; The drop-down menu should be created just once per GEARS change and not on demand to avoid high db-load. Photo could also be added to GEARS.

    Problem is that you have to specify all kinds of GEARS before to get all available columns and be able to combine shoes and shirts (that's why I just used one in the example above) .
    Next to this I wouldn't provide a starting distance for gears since in this case you have to work with triggers and things are getting complex (and ressource consuming). But maybe storing starting distance in a own column in GEARS could solve the problem.

    As a result it would be possible to provide a simple html-table where all values for the used gear can be calculated. Not as fancy as with AJAX but quite functional.

    What do you think ?

    Cheer Eyeless

  9. frold
    Member
    Posted 3 years ago #

    you are welcome to give it a try.. :)

  10. frold
    Member
    Posted 3 years ago #

    Well, a database structure could be:

    CREATE TABLE IF NOT EXISTSgear` (
    gear_id mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
    gear_name varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    gear_type varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    gear_distance varchar(200) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    gear_category varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    gear_bought datetime NOT NULL,
    PRIMARY KEY (id)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;`

    By have a database with id per item stats could be called like:

    [runners_log_gear id="" type=pie year=2010]

    If I have time I will try to play around with it later today eg using mysqlajaxtableeditor.com

  11. TheRealEyeless
    Member
    Posted 3 years ago #

    mmmh, seems good... considering your tableschema above,do you want to save the distance for every gear seperatly or calculate it dynamicly if needed and add it to a "start"-distance (I would appreciate the second idea)?
    If you are working here I will have another look at the weather-front this evening to avoid doing work twice ;)

    Cheers Eyeless

  12. frold
    Member
    Posted 3 years ago #

    My thought was to have a gear table.

    Then in the meta box you specify what gear you have used and the data there is stored is the gear_id.

    To make stats you call the meta box related database, search for the gear_id by using something like this

    [runners_log_gear id="" type=pie year=2010]

    Does it make sense?

  13. TheRealEyeless
    Member
    Posted 3 years ago #

    Yes, I think that's exactly what I meant before ;)

    Cheers Eyeless

  14. frold
    Member
    Posted 3 years ago #

    Hmm Im pretty stocked here :S

    Seems to be over my level...

    I was able to create the database by adding this to runners_log.php

    BEFORE ?>

    /* G E A R   L I S T */
    // Do this when user activates the plugin (Install Script)
    	register_activation_hook( __FILE__, 'gear_list_install');
    
    function gear_list_install(){
    	global $wpdb;
    
    	$table_name = $wpdb->prefix . "gear_list";
    
    	if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
    		$sql = "CREATE TABLE " . $table_name . " (
    		gear_id mediumint(8) unsigned NOT NULL auto_increment,
    		gear_inuse mediumint(8) unsigned NOT NULL,
    		gear_name varchar(100) NOT NULL default '',
    		gear_type varchar(100) NOT NULL default '',
    		gear_category varchar(50) NOT NULL default '',
    		gear_price varchar(100) NOT NULL default '',
    		gear_bought datetime NOT NULL,
    		gear_comment TEXT NOT NULL default '',
    		PRIMARY KEY id (gear_id)
    		);";
    
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);
    
      }
    
    }

    And adding this to create a new submenu:

    AFTER

    function runnerslog_converter_toolbox() {
    		include('Includes/runnerslog_converter_toolbox.php');
    	}

    ADDING

    function runnerslog_gear() {
    		include('Includes/runnerslog_gear.php');
    	}

    AND AFTER

    add_submenu_page('runners-log', 'Coverter Toolbox', 'Coverter Toolbox', 'administrator', 'runners-log-converter-toolbox', 'runnerslog_converter_toolbox');

    ADDING

    add_submenu_page('runners-log', 'Gear List', 'Gear List', 'administrator', 'runners-log-gear-list', 'runnerslog_gear');

    Then in Includes I created runnerslog_gear.php

    and here we have the problem. The fancy tableeditor need some .js files in the head.

    <script type="text/javascript" src="js/prototype.js"></script>
    			<script type="text/javascript" src="js/scriptaculous-js/scriptaculous.js"></script>
    			<script type="text/javascript" src="js/lang/lang_vars-en.js"></script>
    			<script type="text/javascript" src="js/ajax_table_editor.js"></script>
    
    			<!-- calendar files -->
    			<link rel="stylesheet" type="text/css" media="all" href="js/jscalendar/skins/aqua/theme.css" title="win2k-cold-1" />
    			<script type="text/javascript" src="js/jscalendar/calendar.js"></script>
    			<script type="text/javascript" src="js/jscalendar/lang/calendar-en.js"></script>
    			<script type="text/javascript" src="js/jscalendar/calendar-setup.js"></script>

    But howto get them into the <head> - I did try something like this to test - but no result.

    <?php
    add_action('wp_head', 'addtoheader');
    function addtoheader() {
    	echo '<verystrong><verystrong>';
    }
    ?>

    So Im pretty sure Im not able to get the editor to work... Maybe I will have a second try tonight.

  15. TheRealEyeless
    Member
    Posted 3 years ago #

    Good Luck! Rome was not build in one day also ;)
    I don't have an idea currently, don't know wp good enough :-/

    Cheers Eyeless

  16. frold
    Member
    Posted 3 years ago #

    Heheh - you say so...

    I have no more hair - damn its frustrating

  17. frold
    Member
    Posted 3 years ago #

    I think we have breakthrough here... :)

    More info will come :)

  18. TheRealEyeless
    Member
    Posted 3 years ago #

    cool :) , I'll check the new version this evening, first have to take another exam this afternoon ;)

  19. frold
    Member
    Posted 3 years ago #

    Good lock - Im working on it right now, so please re-download the latest dev-version tonight

  20. TheRealEyeless
    Member
    Posted 3 years ago #

    thanks, worked well, not as good as last week but I think the result is going to be satisfying :)

    ok, the gear manager is quite cool :)
    Not as fancy as the examples above, but I think that's exactly the way it should be. And it looks quite nice!

    Sueggestions:
    *I would just make it possible to skip some values when entering new gears, since I lack of information about the buying date of my running shoes.
    *Directly accesing the table from the menu on the left would be cool (now I have to select the manager where I can add new stuff and then select the table)
    *Usage of different kinds of gear and make gears available to select when entering a new blog entry (I just added this two points to get a complete list, I know we discussed it before ;) )

    I think the direction of developement is very good and it's really paying off to put time in this pluin :-)

    Cheers Eyeless

  21. frold
    Member
    Posted 3 years ago #

    Optional fields
    Now Price and Distance is optional.

    Its more difficult to handle optional Boughht date. Because either but day, month and year have to be specified or non of them. Im not able to add that kind of support :S So I kept that mandatory.

    Regarding Distance - that field is a little more tricky and I need to find a solution. Distance should only be editible when you add the item because after that the distance is increased every time you track the use of the item (that's the plan). Else there should be 2 distance fields. One you can edit and one there is set to 0 from start and increased every time you use the item. In the gear-list the distance could be the sum of the 2 distances. What is the best solution?

    Accessing table
    I dont understand this issue... What do you want? Do you miss being able to easy access "items in use", "item not in use"?
    In my localhost you get the gear-manager table when you press the "gear manager icon" in the left. As standart you get the list of items in use.

    Howto integrate the gear list to the meta-box
    Well Im sorry to say but I havent found a solution for that yet. One solution could be a multi-select-drop-down-menu in the meta-box. Here you have list of the "active" items in the gear list. When you select the items the item-id is stored in the data base related to the metabox. But I dont know if I have those skill, yet. And Im not sure howto handle multi values in a database field. If more items is selected how to store the data best? As a list 1,3,5 - If item with it 1 and 3 and 5 is select. Hmm we may take one thing at the time.
    First I want to finish the backend :)

  22. TheRealEyeless
    Member
    Posted 3 years ago #

    Now Price and Distance is optional.

    cool :)

    Because either but day, month and year have to be specified or non of them.

    I thik I don't understand the problem here, I thought that if I know the date I add it and if not I let the three fields empty. May you describe the problem a bit ?

    In the gear-list the distance could be the sum of the 2 distances. What is the best solution?

    IMO this, using two distance fields!

    Accessing table (...) As standart you get the list of items in use.

    Sorry you are right, last night I thought the standart view was "adding a new gear"...now it's working, maybe it was a little late sorry for that 0:-)

    Howto integrate the gear list to the meta-box
    (...)
    First I want to finish the backend :)

    Sure! ;-)

    (An idea could be to create anoter field at the gear-database aka kind like shoe, shirt etc. and for every kind a new drop-down-menu in the meta-box is added [hope you dont wear to much ;) , besides this, storing lists in single DB fields is IMO not good corresponding to runtime, since by this you may delete the advantage of using a DB ])

    Cheers Eyeless

  23. frold
    Member
    Posted 3 years ago #

    About optional bought date
    Well, Im not sure to solve howto control he fields. What if the user enter a bought year and not a day and month? Howto handle that?

    Meta-box
    I still dont know howto do this best - but a field per category was a solution but it could result in tons of fields where you have to choose item from a dropdown menu. That is a very user-unfriendly solution.

    Need to think a little more about that :S

  24. frold
    Member
    Posted 3 years ago #

    If you have time I - and want to - I might need some help finishing the rest of this add-on.

    Im a little stocked here :S

  25. TheRealEyeless
    Member
    Posted 3 years ago #

    sure ;)

    didn't get to far with the weather since my girlfriend wanted to spend the day after my exams with me, but now there is some more time!

    What's up? where get you exactly stuck? I'll have a look at your sources tomorrow, just make your current state and the next step clear to me (as I have seen you already realized the two distance fields :) )

    Cheers Eyeless

  26. frold
    Member
    Posted 3 years ago #

    Thanks!

    Well I think the backend is pretty much done. Maybe I should add a category field, but I dont think we need that one.

    I have started coding a [runners_log_gear] plugin where you specify the id like [runners_log_gear id="2"] to set in the given gear. You find the id in the gear manager list. [runners_log_gear] should give you a list of all you gear that are IN USE. I should be able to do that part.

    The problem is:
    The meta box
    I think the best solution would be that a select box for every item in use is added in the meta box. The user then "check" which items he have used on the course. Im not able to code that :S
    The use should be stored in the database related to the meta box like the other meta box fields: pulse avg, time etc.

    In the gear list database we should have a new field: gear_distance_calculated. gear_distance_calculated should be the sum of the distances the item is used in wordpress. In other words this field is updated every time you use your item (when its cheked in the meta box). The total distance for the item should be: gear_distance + gear_distance_calculated. Does it make sence? In this way gear_distance is a start distance - if you item isnt brand new.

    Im not able to write that mysql to update gear_distance_calculated.

  27. TheRealEyeless
    Member
    Posted 3 years ago #

    Maybe I should add a category field, but I dont think we need that one.

    I think it would help organizing, but I am not sure, too.

    The meta box
    (...) The user then "check" which items he have used on the course.

    Ok, I am currently trying to figure out how the Meta Box is working exactly at the weather front. As soon as I get an idea how to realize this I'll tell you! (might be that the temperature is going to be a little bit fancy ;) ).

    Anyway, for resolving the second problem I consider this as solved ;)

    The total distance for the item should be: gear_distance + gear_distance_calculated. Does it make sence?

    Yes it does!

    In the current version I am unable to create a gear table so I just can assume the available table-columns from source (gear_id|gear_brand|gear_name|gear_price|gear_distance| gear_desc|gear_dateTo|gear_isDone). I consider we have a new column gear_total_distance, that is initialy 0.
    Then the SQL for the first entry should be
    UPDATE wp_gear SET g.gear_total= m._rl_distance_value + g.gear_distance FROM wp_gear g, wp_postmeta m WHERE $post_id = m.meta_id AND g.gear_id = m.gear_id

    after the first usage it would be

    UPDATE wp_gear SET g.gear_total= m._rl_distance_value + g.gear_total_distance FROM wp_gear g, wp_postmeta m WHERE $post_id = m.meta_id AND g.gear_id = m.gear_id

    .... while I am writing this it would also be ok to use just one column for the whole distance. If a new gear is entered it's distance is set and every time the second query could be used and just one distance column would be needed. This would lack the information of the run distance before using the plugin but I don't think that this information is so important.

    Does this resolve your problem?

    Cheers Eyeless

  28. frold
    Member
    Posted 3 years ago #

    I dont understand that mysql :D Its over my level...

    First I think we need to add all the gear items in use to the meta box...

    When you have a better insight in the meta box let me know :)

    I think we need to distance fields in the gear database. Else there could be a problem if the user later edit the distance manually in the gear manager, wouldnt there?

  29. frold
    Member
    Posted 3 years ago #

    btw: My idea was the way to store it in the postmeta database should be something like _rl_gear_item_$id

    Where $id is the of the gear.

  30. TheRealEyeless
    Member
    Posted 3 years ago #

    Ok, your miracle of the day is online, you went to bed 5 minutes too early ;)

    Now the gear table is added to the Metabox, have a look at the code should be quite self explaining(If not just ask ;) ).Adapt it according your needs ;)
    If we change the field "gear_isDone" to "gear_inUse" we could use this directly to select items that should be shown (we just need the opposite value of what we have currently).

    Ok, at this point I am back at the weather front ;)

    Cheers Eyeless

Topic Closed

This topic has been closed to new replies.

About this Topic