[Plugin][GitHub] FeedStatistics - simple stats on your feeds

Post plugins and custom CSS snippets here
jsoares
Bear Rating Trainee
Bear Rating Trainee
Posts: 7
Joined: 05 Jul 2014, 16:16

[Plugin][GitHub] FeedStatistics - simple stats on your feeds

Postby jsoares » 05 Jul 2014, 17:10

Very simple plugin providing some statistics on your feeds.

Info and installation:
ttrss-plugin-feedstatistics

Basic feed statistics for Tiny Tiny RSS. Adds a statistics pane to the feed preferences tab, including both a Google Reader-style one line summary and a table of statistics per feed.

Notes
  1. The table is sorted by posts/day. No way to change this in the preferences, but you can easily change it in the SQL query.
  2. We do not keep track of actual feed activity, but instead only look at the current database. This has a few implications, e.g. we do not keep lifetime read counts. If you don't have purging enabled, you can still get generate them by modifying the default interval (30 days).
  3. The items per day calculation assumes all feeds were followed for the entire interval. If they were recently added, the value will be wrong.

Installation
  1. Upload the feedstatistics directory into [TT-RSS root directory]/plugins.
  2. Set the correct permissions, if neeeded.
  3. Enable the plugin by going to Preferences -> Plugins.

Changelog
v1.00 - Initial Release (2014-07-05)
v1.01 - Made compatible with pgSQL (2014-07-05)
v1.02 - Fixed bug introduced in 1.01 in items/day calculation for low purge delays (2014-07-06)
v1.03 - Now also showing feeds with 0 posts in the period. Version changed to match expected format. (2014-07-08)
v1.04 - Replaced sums with counts (2014-07-08)


The source is on GitHub: https://github.com/jsoares/ttrss-plugin-feedstatistics

Download the zip file, extract feedstatistics to your plugins directory, and enable the plugin. A new pane will show up under Preferences -> Feeds.

Originally requested and dismissed as stupid here.
Attachments
ttrss-plugin-feedstatistics-v1.04.zip
(9.59 KiB) Downloaded 271 times
Last edited by jsoares on 08 Jul 2014, 23:37, edited 5 times in total.

dariottolo
Bear Rating Trainee
Bear Rating Trainee
Posts: 27
Joined: 05 Jul 2014, 18:57

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby dariottolo » 05 Jul 2014, 19:00

I followed the instructions and installed the plugin, but nothing happened. The "Statistics" pane is empty.
I am using Tiny Tiny RSS 1.12 and PostGRE sql.
Let me know if you need additional information.
Regards

jsoares
Bear Rating Trainee
Bear Rating Trainee
Posts: 7
Joined: 05 Jul 2014, 16:16

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby jsoares » 05 Jul 2014, 21:02

It's probably obvious: I forgot that date operations vary depending on the SQL dialect. Thanks for the heads-up, I'll move it to php and post a new version.

vidar
Bear Rating Trainee
Bear Rating Trainee
Posts: 13
Joined: 06 May 2013, 00:19

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby vidar » 05 Jul 2014, 21:10

Also, PostGgeSQL does not support backticks around column names, that's a MySQL abomination.

User avatar
sleeper_service
Bear Rating Overlord
Bear Rating Overlord
Posts: 884
Joined: 30 Mar 2013, 23:50
Location: Dallas, Texas

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby sleeper_service » 05 Jul 2014, 21:16

vidar wrote:Also, PostGgeSQL does not support backticks around column names, that's a MySQL abomination.

why would one want to perpetuate that anyway? I've never backticked a column name in my life. not that I've done all that much sql.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby fox » 05 Jul 2014, 21:29

lots of people literally don't know anything but mysql+php

jsoares
Bear Rating Trainee
Bear Rating Trainee
Posts: 7
Joined: 05 Jul 2014, 16:16

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby jsoares » 05 Jul 2014, 23:14

I have no preference for MySQL, and I absolutely hate php. It just happened to be what I was working with. In any case, backticks fixed, date operations fixed, pgSQL not being able to sum booleans and defaulting to integer division also fixed. Deployed an instance and did some quick testing, should work fine with both backends now.

If you happen to find other bugs, please let me know. As you can probably guess, this was a spur-of-the-moment thing...

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby fox » 05 Jul 2014, 23:18

lol sum booleans what the christ

jsoares
Bear Rating Trainee
Bear Rating Trainee
Posts: 7
Joined: 05 Jul 2014, 16:16

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby jsoares » 06 Jul 2014, 01:27

I'm sure I don't need to explain this, but... The natural representation (and, in most cases, the actual internal representation) for a binary value, such as a boolean, is... as a (0,1) numeral. While nothing requires 1 to be true (you'll find both negative and positive logic in electronic circuits), it's just somewhat intuitive, and sort of a convention since... C, at least.

If you were to count the number of true values in a C array, you would normally do this (or the indexed equivalent):

Code: Select all

for(p=starred;p<starred+N;) {
    count+=*p++;
}


and not this

Code: Select all

for(p=starred;p<starred+N;) {
  if(*p++) {
    count++;
  }
}


C, of course, does not have a boolean type; it's just an integer. However, the same holds true for many languages, where there is an implicit cast from boolean to integer. That is the case for php, making this legal code:

Code: Select all

$array = array(true,false,true);
$count = array_sum($array);


And, for that matter, in MySQL:

Code: Select all

SELECT SUM(starred) FROM ...


Of course, you can come up with counter-examples: IIRC, Ruby does not implicitely cast booleans. And neither does pgsql (but does so on request). Nevertheless, there is nothing conceptually weird about counting binary quantities using a sum. Back to pgsql, I suppose we disagree on which is more elegant:

Code: Select all

SELECT SUM(starred::int) FROM ...


or

Code: Select all

SELECT SUM(CASE WHEN starred THEN 1 ELSE 0 END) FROM ...


In any case, I'm not here to argue which DBMS is better or how to best sum booleans. Thanks for the awesome software :)

nippon
Bear Rating Trainee
Bear Rating Trainee
Posts: 15
Joined: 26 Jun 2013, 05:42

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby nippon » 06 Jul 2014, 03:58

Seems to work. I was not aware of that it would be interesting to know this statistics. Thanks for your plugin.

Here some values from a ttrss test installation with only some feeds:

Code: Select all

From your 16 subscriptions, over the last 5 days you read 830 items, starred 0 items, and published 0 items.
Feed                                  Category          Items  Starred   Published   Items/day
heise online News                     Heise-Verlag      227    0         0           7.57
Caschys Blog                          Specials          108    0         0           3.60
VMware Forum                          Foren             71     0         0           2.37
ComputerBase                          Allgemein         70     0         0           2.33
Tiny Tiny RSS:Forum                   Tiny Tiny RSS     45     0         0           1.50
heise Security                        Heise-Verlag      38     0         0           1.27
Golf 3 Forum                          Auto              37     0         0           1.23
lawblog                               Advokat           17     0         0           0.57
3Dcenter                              Allgemein         12     0         0           0.40
Dell Forum                            Foren             10     0         0           0.33
Zabbix Troubleshooting and Problems   Zabbix            8      0         0           0.27
Kanzlei Hoenig                        Advokat           6      0         0           0.20
Unixhaus                              Specials          4      0         0           0.13
Linux und Ich                         Specials          3      0         0           0.10
Zabbix Weblog                         Zabbix            1      0         0           0.03

jsoares
Bear Rating Trainee
Bear Rating Trainee
Posts: 7
Joined: 05 Jul 2014, 16:16

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby jsoares » 06 Jul 2014, 12:23

Hey nippon, thanks for testing. Unfortunately, it seems I messed up the items/day calculation while testing pgsql (left a hardcoded 30, not accounting for lower purge limits). Uploaded the fix now. Sorry for the annoyance.

AngryChris
Bear Rating Master
Bear Rating Master
Posts: 135
Joined: 08 Apr 2013, 02:42

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby AngryChris » 08 Jul 2014, 01:49

jsoares wrote:I'm sure I don't need to explain this, but... The natural representation (and, in most cases, the actual internal representation) for a binary value, such as a boolean, is... as a (0,1) numeral. While nothing requires 1 to be true (you'll find both negative and positive logic in electronic circuits), it's just somewhat intuitive, and sort of a convention since... C, at least.

[ . . . stuff snipped . . . ]

In any case, I'm not here to argue which DBMS is better or how to best sum booleans. Thanks for the awesome software :)

There is no best way to sum booleans. Summing booleans doesn't make sense. That the value of a boolean can be represented as a 0 or 1 doesn't make them "summable." Today's date is 20140707. This isn't a "number you do math on." It's a date. That you can "sum" booleans in MySQL is a design flaw. Adding booleans together simply because they can be represented by an integer value makes just as much sense as adding them up when they're represented by the letters "Y" or "N" or "T" or "F". To the computer, these are also numbers (89, 78, 84, and 70 respectively) and, like the entire concept of "summing booleans" makes no logical sense.

To be fair, great job on the add-on. I'm glad you scratched an itch, and one that other people seem to feel as well. But this whole adding booleans together thing to achieve some "meaningful" result thing is just ... I couldn't let it go. It's just plain wrong.

jsoares
Bear Rating Trainee
Bear Rating Trainee
Posts: 7
Joined: 05 Jul 2014, 16:16

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby jsoares » 08 Jul 2014, 23:20

Ok, I'll agree with you on language. Summing booleans is conceptually weird. Counting booleans by adding their numerical representations isn't, it's just a practical trick made possible by there being a bijective mapping between the types. In other words, True + True != VeryTrue, but Truth + Truth = 2 Truths. Or just write this off as an old-style embedded system programmer rusty on database languages. Speaking of which, taking your ASCII example, capitalise(char) := char - ' ', although a xor would be smarter ;)

Back on topic, I again updated the plugin to consider feeds with no activity in the period: these will now show in the table, and be counted in the "From your X subscriptions...".

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby fox » 08 Jul 2014, 23:23

if only sql had a count() function hmm

jsoares
Bear Rating Trainee
Bear Rating Trainee
Posts: 7
Joined: 05 Jul 2014, 16:16

Re: [Plugin][GitHub] FeedStatistics - simple stats on your f

Postby jsoares » 08 Jul 2014, 23:41

It wasn't count() that I was overlooking (I just don't like the case notation) but, rather obtusely, nullif(). Thanks fox, sums replaced.


Return to “Themes and plugins”

Who is online

Users browsing this forum: No registered users and 2 guests