Sunday, September 8. 2019
Adding tags to runnerupweb
Another short entry to announce that these weeks I have been working in adding tags to my runnerup backend server. I missed the idea of tagging the activities with meaningful labels that I can use later to search of filter them. That feature has just been added. Remember that runnerupweb is just a toy project that I mainly use to do a backup of my running activities, do not think that it is a full application. My first idea was simply storing the TCX files into my nextcloud server, just that, but, as I already had something developed before, I continued with the idea in order to visualize and get some metrics from the workouts (once runalyze was closed).
The main idea about the tags is that activities can be labeled manually (the activity is marked by the user using the app) or automatically (when the TCX file is uploaded). So now the user can create tags that can be assigned to the workouts. The automatic tags are assigned to the training activity without user interaction and they are created receiving an activity as a sample (that means that the automatic tag takes an activity to obtain some info from it, then the tag can check if another one is assignable or not). The current automatic tags inside the app are the following:
Sport: This tag just checks the sport type of the activity and assign a label to it (running, biking,...).
Location: This tag takes the first track-point of the TCX file and checks if the activity is inside a specific radius (I wanted this because sometimes I run in several cities and I wanted to automatically tag the activities with the city).
Regular expression: Simple tag that uses a PHP regexp over the notes of the TCX file. For example if a tag is created using the expression /race/i any activity uploaded with the word race inside the notes will be tagged with this label.
Route: This is the more complex tag and really the goal I wanted to achieve. I usually do different routes when running (mainly three) and I wanted to automatically tag the TCX file with the route done. The idea is the tag uses the sample activity to get N points and then calculate the distance between the original points and the new activity points, if the accumulated distance is less than a tolerance error (indeed a percent of the distance), the new activity is labeled with the route tag.
Speed and Distance: Another two simple tags that just tag the new activity based on the average speed (for example less than 5 minutes per kilometer) or the total distance of the training (more than 10 km).
Here I present some pictures of how the tags look.
List of user tags:
Using tag filter in the activity list:
Tags inside the activity:
Now I have to upgrade my desktop (real) application. Create my tags and then re-calculate all my files to automatically assign the labels to them. Let's see how it works. If I see no big problems a new tag 0.2.0 will be created for the project.
Regards.
Monday, January 7. 2019
Moving back to RunnerUpWeb
Long time ago I started to develop a silly web aplication that was a backup of my running activities, the application was called RunnerUpWeb and I tried to integrate it inside the RunnerUp phone application. I abandoned the project because members of the community explained me that there was another Runalyze project that was intensively developed as free software (and it was a complete training application, not like my stupidly simple application). I have been using my own Runalyze installation since then but, sadly, Runalyze project is defunct now. I realized about this when the alpha release for RunnerUp was discussed about. I do not know what really happened but the developers of Runalyze has closed the github project and now they are developing the application as proprietary software. It can only be used through its public internet site (like any of the other sites that exist for the same exact purpose).
Therefore very soon I will not be able to synchronize my running activities to Runalyze. The changes I made to make both apps interop are going to disappear (as soon as RunnerUp 2.0 is ready) and only synchronization to the public Runalyze repository will be available. I refuse to use any public repository to store my data (I have already said the same several times in this blog, so I am not going to repeat my reasons again), so I needed a new idea. In the same bug I discovered the death of Runalyze as an open source project I was recommended to just backup my activities using OwnCloud/NextCloud. That was really an easy idea to just maintain a backup of my activities, because I already have a NextCloud server in my desktop for phone maintenance.
RunnerUp phone application can be configured to save a TCX file in a directory inside the phone as soon as the activity is finished. In Settings → Accounts → Tap on the Folder account and configure the directory you want to use to export the activities. I selected the automatic upload to immediately save the file.
Then using the NextCloud application any directory can be configured to be synchronized to the desktop. Settings → Auto Upload → Tap on Set up a custom folder. Configure the same directory used in RunnerUp to automatically be in synch with the NextCloud server (the option to delete the original file was also selected, this way the TCX file is deleted as soon as it is backed up in the server).
So, just using default RunnerUp and NextCloud phone applications my running activities are stored in my own server. My main target was achieved this way. I have a backup of my activities, but, obviously, I was going to lose the possibility of seeing them as I was doing with Runalyze. I do not use any of the other things that Runalyze gives, but I checked some data from time to time (I was running more or less than the previous month or year, faster or slower,...). Finally I decided to reawaken my old RunnerUpWeb project and during this Christmas period I have been working on it. I have tested it with PHP 7.2, moved the web part to npm and react and documented slightly how to install it. And it is working again. It is still very very simple but activities are displayed and some data can be obtained from it.
The last point was how to upload the activities to the new application. Doing something fancy like I tried before with RunnerUp was completely out of my mind (I am tired of that) and having the TCX files in NextCloud makes the things much easier. Now the RunnerUpWeb has a workout.php command line script that let you upload TCX files. This way the RunnerUp application saves the activity in the folder, NextCloud phone app synchs it to the server and finally a cron job uploads that file to RunnerUpWeb (using the workout command line). Easy and effective. I think that now I am safe and no change will ruin this again in the future. I am using plain functionality of the apps. RunnerUpWeb is just a toy project but seeing my activities in the web is very nice. Indeed it is the only thing I missed from Runalyze. So, for the moment, I am done. I will proceed to uninstall my Runalyze setup in a few months if I see everything is working as expected.
Regards.
Tuesday, January 17. 2017
Runalyze installation
Finally everything clumped together and your own server repository (runalyze) can be used to store your running activities (tracked by runnerup). If you have been involved in FOSS projects you already know that the pace is sometimes slow and maybe you have to push at several levels, but, finally, you always get the prize. Of course, you have to know how to develop, but dude, you are not a computering guy if you do not develop (you can read as many books as you want but you are not a writer if you do not try to write one). I learned that long time ago and, since then, I try to collaborate with the projects I use or like.
If you remember first the synchronizer for runalyze was developed and integrated in runnerup. This way the android application can upload your activities to the server backend. Then a painful wait for getting a new version of runnerup with that feature. Obviously in the meantime runalyze evolved and a new fix was necessary for the integration with the newer versions (but this is opensource and another guy did it, thanks a lot!). Then, as a f-droid user, another wait for the runnerup application to be updated in the repository. As it did not come I had to advise them about the new versions. (Another annoying account necessary, why is a fucking user always needed for everything? Only God knows.) Finally some days ago the runnerup 1.56 dropped into f-droid and all the pieces finally fit together. As a side effect I have been involved in the investigation of a proprietary library used in runnerup and I am trying to get rid of it to avoid its exclusion from the free repo. But you know, FOSS is a quid pro quo, a symbiosis, you have to give to be given. I never complain for that.
As I said now the pieces fit and this is my little how-to about installing runalyze in my server. Remember I already have a nextcloud server installed in the same desktop, so, several previous steps are missing. I followed the documentation given by the project. You have to be root for the whole procedure.
As you now I use debian testing as my linux default system (maybe I have to change that, but this is another story) and, first, you have to install several system packages (mainly php modules). The complete list in the runalyze documentation but in my case I only needed one missing package:
apt-get install php-gettext
Then download and uncompress the runalyze application itself. I installed it in the default debian directory for web apps (/var/www) and I created a link to make later upgrades easier.
cd /var/www wget https://github.com/Runalyze/Runalyze/releases/download/v3.1.0/runalyze-v3.1.0.zip unzip runalyze-v3.1.0.zip mv runalyze runalyze-v3.1.0 ln -s runalyze-v3.1.0 runalyze cd runalyze chown -R www-data:www-data *
Create the user and the database for the application. As I said I am going to re-use previous mariadb and apache2 already installed in the system.
create database runalyze; create user 'runalyze'@'localhost' IDENTIFIED BY 'XXXXXX'; grant all on runalyze.* to 'runalyze'@'localhost';
Configure the database access in the config.yml file. Just the username and the password are needed because all the other information is the same (localhost, database name and so on, take care if you change the default values).
Now you need to configure the directory inside the apache2 server. Remember I already have an ssl virtual host and the certificate perfectly configured in my phone to accept that web server. So I just needed to add the following lines to my secure site (/etc/apache2/sites-enabled/default-ssl.conf):
# runalyze Alias /runalyze/ "/var/www/runalyze/web/" <Directory /var/www/runalyze/web> AllowOverride None Require all granted <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app.php [QSA,L] </IfModule> </Directory>
At this point I needed to enable the rewrite module (as you see in the previous configuration it is needed for runalyze) and restart the apache server.
a2enmod rewrite systemctl restart apache2
Now you have to access to the install page (https://venom.local/runalyze/install in my case) and execute the process that populates the database.
After the population you are requested to create the first user.
In my case the creation failed because I have no email server configured (and I am not going to have one). The server tries to send an activation code to your mail (like if it was a real internet account). Just remove the activation directly in the database and enable the user (take care, this command activates all the users in the ddbb, but in this step there should be only one):
update runalyze_account set activation_hash=null;
Finally you have a running runalyze server in your own PC. You can access to your empty account to test it.
The last step is configuring your runnerup account and upload all your activities to the server. This process is the same that was explained when I presented the integration. And remember I have an https web server, which means I have to install my certificate in the phone. As I said this procedure is not absolutely complete because part of the steps were already done in the installation of nextcloud.
cp app/config/default_config.yml data/config.yml
And modify the options for the user and password to use:
database_user: runalyze database_password: XXXXXX
And that is all. It is really nice when you see everything comes together. I do not know if I said this before in the blog but it is a thought that came to me several years ago. Every computering dude should dedicate a few hours per week helping in some FOSS projects. Just the one you are comfortable working to, you like to work on or you use everyday. It is not an obligation. It should be intended more like a hobby. The number of hours is not important. Some weeks you can work a lot, and others you can contribute nothing. Think that working in real projects give you experience and visibility to companies too. It is another way of making your curriculum more interesting. Besides you are freeing yourself and, in the way a lot of people, from the dictatorship of googles, facebooks, apples,... I know they are smarter than us and they have always a plan but remember we are legion. Obviously check permanently the trust of the projects you are contributing to and, at the slightest doubt, stop and reconsider it again.
Regards!
Comments