Skip to content

Commit 4e93bbf

Browse files
committed
Add intial delta work and comment on how to extend.
1 parent 0147cb1 commit 4e93bbf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Delta a list of changes on Jupiter after a given date
2+
# base on https://github.com/ualbertalib/jupiter/pull/3626/files
3+
4+
5+
class ChangesReport
6+
7+
def initialize(output_directory, date)
8+
@date = date
9+
@output_file = output_directory + "#{date}_changes.csv"
10+
end
11+
12+
def perform()
13+
CSV.open(@output_file, 'wb') do |csv|
14+
csv << ['type', 'id', 'changed at', 'event', 'delta']
15+
PaperTrail::Version.where(created_at: @date..).find_each do |row|
16+
# change delta for Item & Thesis type converting end result
17+
# to DSpace/Scholaris key/value by extending the linked method
18+
# test if the key exsists in the object_changes and creating a new
19+
# structure in a new column listing the Scholaris key/value pairs to update
20+
# https://gist.github.com/lagoan/839cf8ce997fa17b529d84776b91cdac#file-export_collections_csv-rb-L181-L196
21+
csv << [row.item_type, row.item_id, row.created_at, row.event, row.object_changes]
22+
end
23+
end
24+
25+
i = Item.updated_on_or_after(@date).count
26+
t = Thesis.updated_on_or_after(@date).count
27+
cl = Collection.updated_on_or_after(@date).count
28+
cm = Community.updated_on_or_after(@date).count
29+
summary = "#{i} items, #{t} theses, #{cl} collections and #{cm} communities were created or modified."
30+
puts(summary)
31+
32+
end
33+
34+
end
35+
36+
ChangesReport.new("/tmp/",Date.new(2005, 8, 8)).perform()

0 commit comments

Comments
 (0)