File tree Expand file tree Collapse file tree 4 files changed +22
-16
lines changed Expand file tree Collapse file tree 4 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ def execute
10
10
criteria . each do |problem |
11
11
ProblemDestroy . new ( problem ) . execute
12
12
end
13
- repair_database
13
+ compact_database
14
14
end
15
15
end
16
16
end
@@ -25,7 +25,10 @@ def criteria
25
25
@criteria ||= Problem . where ( :last_notice_at . lt => Errbit ::Config . notice_deprecation_days . to_f . days . ago )
26
26
end
27
27
28
- def repair_database
29
- Mongoid . default_client . command repairDatabase : 1
28
+ def compact_database
29
+ collections = Mongoid . default_client . collections
30
+ collections . map ( &:name ) . map do |collection |
31
+ Mongoid . default_client . command compact : collection
32
+ end
30
33
end
31
34
end
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ def execute
10
10
criteria . each do |problem |
11
11
ProblemDestroy . new ( problem ) . execute
12
12
end
13
- repair_database
13
+ compact_database
14
14
end
15
15
end
16
16
end
@@ -25,7 +25,10 @@ def criteria
25
25
@criteria = Problem . resolved
26
26
end
27
27
28
- def repair_database
29
- Mongoid . default_client . command repairDatabase : 1
28
+ def compact_database
29
+ collections = Mongoid . default_client . collections
30
+ collections . map ( &:name ) . map do |collection |
31
+ Mongoid . default_client . command compact : collection
32
+ end
30
33
end
31
34
end
Original file line number Diff line number Diff line change 22
22
Problem . count
23
23
}
24
24
end
25
- it 'not repair database' do
25
+ it 'not compact database' do
26
26
allow ( Mongoid . default_client ) . to receive ( :command ) . and_call_original
27
- expect ( Mongoid . default_client ) . to_not receive ( :command ) . with ( repairDatabase : 1 )
27
+ expect ( Mongoid . default_client ) . to_not receive ( :command ) . with ( compact : an_instance_of ( String ) )
28
28
outdated_problem_clearer . execute
29
29
end
30
30
end
31
31
32
32
context "with old problems" do
33
33
before do
34
34
allow ( Mongoid . default_client ) . to receive ( :command ) . and_call_original
35
- allow ( Mongoid . default_client ) . to receive ( :command ) . with ( repairDatabase : 1 )
35
+ allow ( Mongoid . default_client ) . to receive ( :command ) . with ( compact : an_instance_of ( String ) ) . at_least ( 1 )
36
36
problems . first . update ( last_notice_at : Time . zone . at ( 946_684_800.0 ) )
37
37
problems . second . update ( last_notice_at : Time . zone . at ( 946_684_800.0 ) )
38
38
end
47
47
expect ( Problem . where ( _id : problems . second . id ) . first ) . to be_nil
48
48
end
49
49
50
- it 'repair database' do
51
- expect ( Mongoid . default_client ) . to receive ( :command ) . with ( repairDatabase : 1 )
50
+ it 'compact database' do
51
+ expect ( Mongoid . default_client ) . to receive ( :command ) . with ( compact : an_instance_of ( String ) ) . at_least ( 1 )
52
52
outdated_problem_clearer . execute
53
53
end
54
54
end
Original file line number Diff line number Diff line change 18
18
Problem . count
19
19
}
20
20
end
21
- it 'not repair database' do
21
+ it 'not compact database' do
22
22
allow ( Mongoid . default_client ) . to receive ( :command ) . and_call_original
23
- expect ( Mongoid . default_client ) . to_not receive ( :command ) . with ( repairDatabase : 1 )
23
+ expect ( Mongoid . default_client ) . to_not receive ( :command ) . with ( compact : an_instance_of ( String ) )
24
24
resolved_problem_clearer . execute
25
25
end
26
26
end
27
27
28
28
context "with problem resolve" do
29
29
before do
30
30
allow ( Mongoid . default_client ) . to receive ( :command ) . and_call_original
31
- allow ( Mongoid . default_client ) . to receive ( :command ) . with ( repairDatabase : 1 )
31
+ allow ( Mongoid . default_client ) . to receive ( :command ) . with ( compact : an_instance_of ( String ) ) . at_least ( 1 )
32
32
problems . first . resolve!
33
33
problems . second . resolve!
34
34
end
43
43
expect ( Problem . where ( _id : problems . second . id ) . first ) . to be_nil
44
44
end
45
45
46
- it 'repair database' do
47
- expect ( Mongoid . default_client ) . to receive ( :command ) . with ( repairDatabase : 1 )
46
+ it 'compact database' do
47
+ expect ( Mongoid . default_client ) . to receive ( :command ) . with ( compact : an_instance_of ( String ) ) . at_least ( 1 )
48
48
resolved_problem_clearer . execute
49
49
end
50
50
end
You can’t perform that action at this time.
0 commit comments