From 7562cd2dffd318b1b3976aaf959e42f4e8e46cec Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 3 Feb 2017 08:56:40 +0100 Subject: [PATCH] Implemented issue #722 - Do not log last_login in user history. --- app/models/user.rb | 1 + ...0203000001_remove_last_login_from_history_722.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 db/migrate/20170203000001_remove_last_login_from_history_722.rb diff --git a/app/models/user.rb b/app/models/user.rb index cb75eb530..d0af3c6b9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -63,6 +63,7 @@ class User < ApplicationModel :preferences history_attributes_ignored :password, + :last_login, :image, :image_source, :preferences diff --git a/db/migrate/20170203000001_remove_last_login_from_history_722.rb b/db/migrate/20170203000001_remove_last_login_from_history_722.rb new file mode 100644 index 000000000..ddb3a77d3 --- /dev/null +++ b/db/migrate/20170203000001_remove_last_login_from_history_722.rb @@ -0,0 +1,13 @@ +class RemoveLastLoginFromHistory722 < ActiveRecord::Migration + def up + + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + history_object = History.object_lookup('User') + return if !history_object + history_attribute = History.attribute_lookup('last_login') + return if !history_attribute + History.where(history_object_id: history_object.id, history_attribute_id: history_attribute.id).delete_all + end +end