blob: a6e0b333497d833ebd8a8d9b32df975fea55523b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
require 'singleton'
class CommitRepository < BaseRepository
include Singleton
client ElasticsearchClient.default
index_name "commit-#{Rails.env}"
klass Commit
mapping dynamic: 'strict' do
indexes :id, type: 'keyword'
indexes :author, type: 'keyword'
indexes :email, type: 'keyword'
indexes :date, type: 'date'
indexes :message, type: 'text'
indexes :files do
indexes :modified, type: 'keyword'
indexes :deleted, type: 'keyword'
indexes :added, type: 'keyword'
end
indexes :packages, type: 'keyword'
indexes :created_at, type: 'date'
indexes :updated_at, type: 'date'
end
# Parse the "created_at" and "updated_at" fields in the document
#
def deserialize(document)
hash = document['_source']
hash['created_at'] = Time.parse(hash['created_at']).utc if hash['created_at']
hash['updated_at'] = Time.parse(hash['updated_at']).utc if hash['updated_at']
Commit.new hash
end
end
|