enju_search_log 0.1.0.pre9 → 0.1.0.pre10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +8 -1
- data/app/models/search_history.rb +3 -3
- data/lib/enju_search_log/engine.rb +1 -1
- data/lib/enju_search_log/user.rb +8 -4
- data/lib/enju_search_log/version.rb +1 -1
- data/spec/dummy/config/boot.rb +2 -2
- data/spec/dummy/config/database.yml +23 -18
- data/spec/dummy/db/migrate/002_devise_create_users.rb +46 -0
- data/spec/dummy/db/migrate/041_create_roles.rb +13 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +28 -0
- data/spec/dummy/db/migrate/069_create_shelves.rb +15 -0
- data/spec/dummy/db/migrate/077_create_user_groups.rb +12 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +0 -1
- data/spec/dummy/db/migrate/120_create_baskets.rb +12 -0
- data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -0
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +12 -0
- data/spec/dummy/db/migrate/131_create_request_types.rb +12 -0
- data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +17 -0
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +14 -0
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +17 -0
- data/spec/dummy/db/migrate/20091202124834_create_versions.rb +18 -0
- data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +9 -0
- data/spec/dummy/db/migrate/{20111201163718_create_user_has_roles.rb → 20100606065209_create_user_has_roles.rb} +2 -0
- data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +11 -0
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +5 -0
- data/spec/dummy/db/migrate/{20111201121844_create_roles.rb → 20120129014038_create_budget_types.rb} +2 -2
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +14 -0
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
- data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +16 -0
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +6 -0
- data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +18 -0
- data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +11 -0
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +11 -0
- data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +11 -0
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
- data/spec/dummy/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +5 -0
- data/spec/dummy/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +5 -0
- data/spec/dummy/db/schema.rb +292 -49
- data/spec/fixtures/users.yml +1 -1
- data/spec/spec_helper.rb +5 -0
- metadata +112 -26
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +0 -13
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +0 -52
- data/spec/dummy/db/test.sqlite3 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d0ad6e688f24e9c0b9fb97c365d8698e479eeca
|
4
|
+
data.tar.gz: 526fa650eebcb495f348cbe7990471294f89e5b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9308416667b6ed73469b88b0345d155dc8f15d92835d437e68931e7264452b01cc90031aa0eb05a329bd7cfff6026a3f4d94f85d16bfc9f21a7c0217fbcf3397
|
7
|
+
data.tar.gz: 8eaa1e25188c999519673d28beb4df5d51663f464a0b6f156cb20a016c27e9ca6b6c34f4002cf8311d7187828a68159721f158b27107793cbaabf67cb918aa7b
|
data/README.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
1
|
= EnjuSearchLog
|
2
|
+
{<img src="https://secure.travis-ci.org/next-l/enju_search_log.png?branch=1.1" alt="Build Status" />}[http://travis-ci.org/next-l/enju_search_log]
|
3
|
+
{<img src="https://coveralls.io/repos/next-l/enju_search_log/badge.png?branch=1.1" alt="Coverage Status" />}[https://coveralls.io/r/next-l/enju_search_log?branch=1.1]
|
4
|
+
{<img src="https://hakiri.io/github/next-l/enju_search_log/1.1.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_search_log/1.1]
|
2
5
|
|
3
|
-
This project rocks and uses MIT-LICENSE.
|
6
|
+
This project rocks and uses MIT-LICENSE.
|
7
|
+
|
8
|
+
== 製作者・貢献者 (Authors and contributors)
|
9
|
+
* {TANABE, Kosuke}[https://github.com/nabeta] ({@nabeta}[https://twitter.com/nabeta])
|
10
|
+
* {Project Next-L}[http://www.next-l.jp] ({@ProjectNextL}[https://twitter.com/ProjectNextL])
|
@@ -5,18 +5,18 @@ class SearchHistory < ActiveRecord::Base
|
|
5
5
|
:result_set_idle_time, :records, :next_record_position, :diagnostics,
|
6
6
|
:extra_response_data, :echoed_search_retrieve_request
|
7
7
|
|
8
|
-
scope :not_found, where(:
|
8
|
+
scope :not_found, -> { where(number_of_records: 0) }
|
9
9
|
belongs_to :user
|
10
10
|
|
11
11
|
paginates_per 10
|
12
12
|
|
13
13
|
# http://d.hatena.ne.jp/rubyco/20070528
|
14
14
|
def self.not_found_query(number, duration = 1.year.ago)
|
15
|
-
self.not_found.where('created_at > ?', duration).all.collect(&:query).inject(Hash.new(0)){|r,e|r[e]+=1;r}.to_a.collect{|q| q if q[1] >= number.to_i}.compact
|
15
|
+
self.not_found.where('created_at > ?', duration).all.collect(&:query).inject(Hash.new(0)){|r,e| r[e] += 1; r}.to_a.collect{|q| q if q[1] >= number.to_i}.compact
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.remove_all_history(user)
|
19
|
-
user.search_histories.update_all(:
|
19
|
+
user.search_histories.update_all(user_id: nil)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
data/lib/enju_search_log/user.rb
CHANGED
@@ -7,7 +7,7 @@ module EnjuSearchLog
|
|
7
7
|
module ClassMethods
|
8
8
|
def enju_search_log_user_model
|
9
9
|
include InstanceMethods
|
10
|
-
has_many :search_histories, :
|
10
|
+
has_many :search_histories, dependent: :destroy
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -17,14 +17,18 @@ module EnjuSearchLog
|
|
17
17
|
if Setting.write_search_log_to_file
|
18
18
|
write_search_log(query, total, username, format)
|
19
19
|
else
|
20
|
-
history = SearchHistory.new(:
|
20
|
+
history = SearchHistory.new(query: query, start_record: offset + 1, maximum_records: nil, number_of_records: total)
|
21
21
|
history.user = self
|
22
|
-
history.save(:
|
22
|
+
history.save(validate: false)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def write_search_log(query, total, username, format)
|
27
|
-
|
27
|
+
if Rails::VERSION::MAJOR >= 4
|
28
|
+
logger = ActiveSupport::Logger.new(File.join(Rails.root, 'log', 'search.log'))
|
29
|
+
else
|
30
|
+
logger = ActiveSupport::BufferedLogger.new(File.join(Rails.root, 'log', 'search.log'))
|
31
|
+
end
|
28
32
|
logger.info "#{Time.zone.now}\t#{query}\t#{total}\t#{username}\t#{format}"
|
29
33
|
end
|
30
34
|
end
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
2
|
+
gemfile = ENV['BUNDLE_GEMFILE'] || File.expand_path('../../../../Gemfile', __FILE__)
|
3
3
|
|
4
4
|
if File.exist?(gemfile)
|
5
5
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -7,4 +7,4 @@ if File.exist?(gemfile)
|
|
7
7
|
Bundler.setup
|
8
8
|
end
|
9
9
|
|
10
|
-
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
10
|
+
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -1,25 +1,30 @@
|
|
1
|
-
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
development:
|
1
|
+
sqlite: &sqlite
|
7
2
|
adapter: sqlite3
|
8
|
-
database: db
|
3
|
+
database: db/<%= Rails.env %>.sqlite3
|
4
|
+
|
5
|
+
mysql: &mysql
|
6
|
+
adapter: mysql2
|
7
|
+
username: root
|
8
|
+
password:
|
9
|
+
database: enju_<%= Rails.env %>
|
10
|
+
|
11
|
+
postgresql: &postgresql
|
12
|
+
adapter: postgresql
|
13
|
+
username: postgres
|
14
|
+
password:
|
15
|
+
database: enju_<%= Rails.env %>
|
16
|
+
|
17
|
+
defaults: &defaults
|
9
18
|
pool: 5
|
10
19
|
timeout: 5000
|
20
|
+
host: localhost
|
21
|
+
<<: *<%= ENV['DB'] || "sqlite" %>
|
22
|
+
|
23
|
+
development:
|
24
|
+
<<: *defaults
|
11
25
|
|
12
|
-
# Warning: The database defined as "test" will be erased and
|
13
|
-
# re-generated from your development database when you run "rake".
|
14
|
-
# Do not set this db to the same as development or production.
|
15
26
|
test:
|
16
|
-
|
17
|
-
database: db/test.sqlite3
|
18
|
-
pool: 5
|
19
|
-
timeout: 5000
|
27
|
+
<<: *defaults
|
20
28
|
|
21
29
|
production:
|
22
|
-
|
23
|
-
database: db/production.sqlite3
|
24
|
-
pool: 5
|
25
|
-
timeout: 5000
|
30
|
+
<<: *defaults
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class DeviseCreateUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table(:users) do |t|
|
4
|
+
## Database authenticatable
|
5
|
+
t.string :email, :null => false, :default => ""
|
6
|
+
t.string :encrypted_password, :null => false, :default => ""
|
7
|
+
|
8
|
+
## Recoverable
|
9
|
+
t.string :reset_password_token
|
10
|
+
t.datetime :reset_password_sent_at
|
11
|
+
|
12
|
+
## Rememberable
|
13
|
+
t.datetime :remember_created_at
|
14
|
+
|
15
|
+
## Trackable
|
16
|
+
t.integer :sign_in_count, :default => 0
|
17
|
+
t.datetime :current_sign_in_at
|
18
|
+
t.datetime :last_sign_in_at
|
19
|
+
t.string :current_sign_in_ip
|
20
|
+
t.string :last_sign_in_ip
|
21
|
+
|
22
|
+
## Confirmable
|
23
|
+
# t.string :confirmation_token
|
24
|
+
# t.datetime :confirmed_at
|
25
|
+
# t.datetime :confirmation_sent_at
|
26
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
27
|
+
|
28
|
+
## Lockable
|
29
|
+
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
30
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
31
|
+
# t.datetime :locked_at
|
32
|
+
|
33
|
+
## Token authenticatable
|
34
|
+
# t.string :authentication_token
|
35
|
+
|
36
|
+
|
37
|
+
t.timestamps
|
38
|
+
end
|
39
|
+
|
40
|
+
add_index :users, :email, :unique => true
|
41
|
+
add_index :users, :reset_password_token, :unique => true
|
42
|
+
# add_index :users, :confirmation_token, :unique => true
|
43
|
+
# add_index :users, :unlock_token, :unique => true
|
44
|
+
# add_index :users, :authentication_token, :unique => true
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateRoles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table "roles" do |t|
|
4
|
+
t.column :name, :string, :null => false
|
5
|
+
t.column :display_name, :string
|
6
|
+
t.column :note, :text
|
7
|
+
t.column :created_at, :datetime
|
8
|
+
t.column :updated_at, :datetime
|
9
|
+
t.integer :score, :default => 0, :null => false
|
10
|
+
t.integer :position
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateLibraries < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :libraries do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.string :short_display_name, :null => false
|
7
|
+
t.string :zip_code
|
8
|
+
t.text :street
|
9
|
+
t.text :locality
|
10
|
+
t.text :region
|
11
|
+
t.string :telephone_number_1
|
12
|
+
t.string :telephone_number_2
|
13
|
+
t.string :fax_number
|
14
|
+
t.text :note
|
15
|
+
t.integer :call_number_rows, :default => 1, :null => false
|
16
|
+
t.string :call_number_delimiter, :default => "|", :null => false
|
17
|
+
t.integer :library_group_id, :default => 1, :null => false
|
18
|
+
t.integer :users_count, :default => 0, :null => false
|
19
|
+
t.integer :position
|
20
|
+
t.integer :country_id
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
t.datetime :deleted_at
|
24
|
+
end
|
25
|
+
add_index :libraries, :library_group_id
|
26
|
+
add_index :libraries, :name, :unique => true
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateShelves < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :shelves do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.text :note
|
7
|
+
t.integer :library_id, :default => 1, :null => false
|
8
|
+
t.integer :items_count, :default => 0, :null => false
|
9
|
+
t.integer :position
|
10
|
+
t.timestamps
|
11
|
+
t.datetime :deleted_at
|
12
|
+
end
|
13
|
+
add_index :shelves, :library_id
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateBookstores < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :bookstores do |t|
|
4
|
+
t.text :name, :null => false
|
5
|
+
t.string :zip_code
|
6
|
+
t.text :address
|
7
|
+
t.text :note
|
8
|
+
t.string :telephone_number
|
9
|
+
t.string :fax_number
|
10
|
+
t.string :url
|
11
|
+
t.integer :position
|
12
|
+
t.datetime :deleted_at
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateSubscriptions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :subscriptions do |t|
|
4
|
+
t.text :title, :null => false
|
5
|
+
t.text :note
|
6
|
+
#t.integer :subscription_list_id, :integer
|
7
|
+
t.integer :user_id
|
8
|
+
t.integer :order_list_id
|
9
|
+
t.datetime :deleted_at
|
10
|
+
t.integer :subscribes_count, :default => 0, :null => false
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
add_index :subscriptions, :user_id
|
15
|
+
add_index :subscriptions, :order_list_id
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateSubscribes < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :subscribes do |t|
|
4
|
+
t.integer :subscription_id, :null => false
|
5
|
+
t.integer :work_id, :null => false
|
6
|
+
t.datetime :start_at, :null => false
|
7
|
+
t.datetime :end_at, :null => false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :subscribes, :subscription_id
|
12
|
+
add_index :subscribes, :work_id
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateSearchEngines < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :search_engines do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.string :url, :null => false
|
7
|
+
t.text :base_url, :null => false
|
8
|
+
t.text :http_method, :null => false
|
9
|
+
t.text :query_param, :null => false
|
10
|
+
t.text :additional_param
|
11
|
+
t.text :note
|
12
|
+
t.integer :position
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateVersions < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :versions do |t|
|
4
|
+
t.string :item_type, :null => false
|
5
|
+
t.integer :item_id, :null => false
|
6
|
+
t.string :event, :null => false
|
7
|
+
t.string :whodunnit
|
8
|
+
t.text :object
|
9
|
+
t.datetime :created_at
|
10
|
+
end
|
11
|
+
add_index :versions, [:item_type, :item_id]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
remove_index :versions, [:item_type, :item_id]
|
16
|
+
drop_table :versions
|
17
|
+
end
|
18
|
+
end
|