class Osm::Myscout::ParentLoginHistory
Constants
- SORT_BY
Public Class Methods
get_for_section(api, section, options={})
click to toggle source
Get parent login history @param [Osm::Api] api The api to use to make the request @param [Osm::Section, Fixnum, to_i
] section The section (or its ID) to get login history for @!macro options_get @return [Array<Osm::Myscout::ParentLoginHistory>]
# File lib/osm/myscout.rb, line 45 def self.get_for_section(api, section, options={}) section_id = section.to_i require_ability_to(api, :read, :member, section, options) cache_key = ['myscout', 'parent_login_history', section_id] if !options[:no_cache] && cache_exist?(api, cache_key) return cache_read(api, cache_key) end data = api.perform_query("ext/settings/parents/loginhistory/?action=getLoginHistory§ionid=#{section_id}") return [] unless data.is_a?(Hash) data = data['items'] return [] unless data.is_a?(Array) data.map! do |item| new( member_id: Osm::to_i_or_nil(item['scoutid']), first_name: item['firstname'], last_name: item['lastname'], logins: Osm::to_i_or_nil(item['numlogins']), last_login: get_last_login_date(item['lastlogin'],) ) end cache_write(api, cache_key, data) return data end
Private Class Methods
get_last_login_date(date_str)
click to toggle source
# File lib/osm/myscout.rb, line 74 def self.get_last_login_date(date_str) return nil if date_str.nil? return nil if date_str.eql?('Invitation not sent') Time.strptime(date_str, '%d/%m/%Y %H:%M') end