Keep track of when an item was last active

simur612

Member
May 25, 2018
879
0
16
rtorrent Community Wiki
The above article describes how to add a timestamp to torrents showing last activity.

I've added the required code in .rtorrent.rc and restarted rtorrent, but I don't see this extra field in rutorrent.
The question is how to display this new value in rutorrent?
 

randac56

Member
May 25, 2018
915
0
16
I've managed to edit the code to add the new field to the rutorrent webui, but how to create and call this new function last active in the new column?

Do I need an id: "last_active"?

www/rutorrent/js/webui.js
Code:
{ text: theUILang.last_active, width: "100px", id: "created", type: TYPE_NUMBER }
www/rutorrent/lang/en.js
Code:
last_active : "Last Active",
 

peshua19

Member
May 25, 2018
897
0
16
After some poking around I can see some of the other fields are called from rtorrent.js
eg. in /rutorrent/js/webui.js
Code:
{ text: theUILang.Remaining, width: "90px", id: "remaining", type: TYPE_NUMBER }is called from rtorrent.js as:
Code:
torrent.remaining = this.getValue(values,20);

So after some playing around I managed to call the torrent comments into my new Last Active field by editing rutorrent/js/webui.js like this just to test:
Code:
{ text: theUILang.last_active, width: "100px", id: "comment", type: TYPE_STRING}
Soooo....

The new quesion is:
Is there a "value" so I can add torrent.last_active = this.getValue(values,??) to rtorrent.js which will call the new last_active code added to rtorrent.rc or are these values only a set of defualt values that are added when rtorrent is compiled?

I feel close to the solution, but am probably still very far away!
 

lisas4567

Member
May 25, 2018
773
0
16
1) I can't understand, for which reason you need such strange thing - 'last activity'. You already have ratio/per day/per week/per month for each torrent. And all traffic statistic (per day, month, year) for each torrent (plugin trafic).
2) If you want to add a new field to torrent's table, don't touch the file torrent.js. See plugin 'seedingtime' as example. Or plugin 'trafic'. Or plugin 'ratio' - all of its contain code of addition of new column.
 

saroos1

Member
May 25, 2018
718
0
16
Then I can't understand why your community wiki has an article showing how to enable last_activity.
Someone else must be using it for rtorrent otherwise why that article?

Code:
# SCHEDULE: Set "last_active" custom field for items that have peers
system.method.insert = d.last_active, simple|value, "if=$d.peers_connected=,$system.time=,$d.custom=last_active"
schedule = update_last_active,24,42,"d.multicall=started,\"branch=$d.peers_connected=,\\\"d.custom.set=last_active,$cat=$system.time=\\\"\""
system.method.insert = d.print_last_active, simple, "print=\"$cat={$convert.date=$d.last_active=, \\\" \\\", $convert.time=$d.last_active=}\""

I will look at the plugin code, thanks for that, but I'm not sure it will show me how to call this new last_activity value?
 

randac56

Member
May 25, 2018
915
0
16
Then I can't understand why your community
My??? I'm not an owner or member of this community. This is a *rtorrent* community, not *ruTorrent*.
I will look at the plugin code, thanks for that, but I'm not sure it will show me how to call this new last_activity value?
It will show to you how to add a new column to the torrents list of the ruTorrent UI
 

randac56

Member
May 25, 2018
915
0
16
grin.gif

By hands.
Is that russian for fuck off and do it yourself?


Had a look at the seedtime plugin and I guess I need to try and hack that.
 

peshua19

Member
May 25, 2018
897
0
16
Ok, so looking at init.js I think I can see the function that adds the timestamp for seedingtime.

Code:
for(var i in arr)
{
var s = table.getIdByCol(i);
if(s=="seedingtime")
arr = arr ? theConverter.time(new Date().getTime()/1000-(iv(arr)+theWebUI.deltaTime/1000),true) : "";
else
if(s=="addtime")
arr = arr ? theConverter.date(iv(arr)+theWebUI.deltaTime/1000) : "";
}
I think I can adjust most of the other code to suit, but it's the actual code of grabbing the last_active data from rtorrent that I can't work out.
Your code grabs the system time when a torrent is added, completed or rehashed.
This of course is nothing like grabbing a value from rtorrent, so I'm stuck.
 

lisas4567

Member
May 25, 2018
773
0
16
Is this last_active column not something that could be added to the seedingtime plugin?
It seems the logical place to add this additional variable.
 

saroos1

Member
May 25, 2018
718
0
16
Your code grabs the system time when a torrent is added, completed or rehashed.
This of course is nothing like grabbing a value from rtorrent, so I'm stuck.
Actually, if i am correct, this almost exactly the behavior that you are looking for. Looking at the seedingtime plugin, the file init.php is used to set custom fields in "rtorrent" which are then called in the file init.js. You can also see more examples of this by looking at init.php of other plugins. wink.gif
 

randac56

Member
May 25, 2018
915
0
16
Fair enough. I've already checked other plugins and can grasp the basic concept, but I still don't fully understand the rtorrent and rutorrent calls enough to adapt them to suit.
Looks like I need to learn.