delian / node-unifiapi

UniFi API ported to Node.JS
GNU General Public License v3.0
49 stars 19 forks source link

Bug in implementation of UnifiAPI.stat_sta_sessions_latest #15

Open shankscoder opened 6 years ago

shankscoder commented 6 years ago

So looks like there're some typos in this function, here: https://github.com/delian/node-unifiapi/blob/34662c589f2a9b0e8aa2069a2fd202e9be55476b/index.js#L332

The current code looks like so:

UnifiAPI.prototype.stat_sta_sessions_latest = function(mac = '', limit = 5, sort = '-asoc-time', site = undefined) {   
    return this.netsite('/stat/sessions', {   
        mac: mac.toLowerCase(),   
        '_limit': limit,   
        '_sort': sort   
    }, {}, undefined, site);   
};

This returns an empty dataset, for 2 reasons:

  1. The API to call is going to /stat/sessions not /stat/session.
  2. The sorting parameter should be -assoc_time not -asoc-time

Putting this here right now as I'm still working through other calls to try and debug if there are any issues. If I aggregate a few more I'll create a pull request to consolidate these changes.

delian commented 6 years ago

Ok, I will fix it. But if you find more problems, please tell

Delian

On Sun, Aug 5, 2018 at 3:14 PM Ashwin Shankar notifications@github.com wrote:

So looks like there're some typos in this function, here: https://github.com/delian/node-unifiapi/blob/34662c589f2a9b0e8aa2069a2fd202e9be55476b/index.js#L332

The current code looks like so:

UnifiAPI.prototype.stat_sta_sessions_latest = function(mac = '', limit = 5, sort = '-asoc-time', site = undefined) { return this.netsite('/stat/sessions', { mac: mac.toLowerCase(), '_limit': limit, '_sort': sort }, {}, undefined, site); };

This returns an empty dataset, for 2 reasons:

  1. The API to call is going to /stat/sessions not /stat/session.
  2. The sorting parameter should be -assoc_time not -asoc-time

Putting this here right now as I'm still working through other calls to try and debug if there are any issues. If I aggregate a few more I'll create a pull request to consolidate these changes.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/delian/node-unifiapi/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZkduvrKL-AKL_ZhHyYgfoqS7AJByks5uNuGJgaJpZM4VvWnY .