Skip to content

Commit 201281f

Browse files
DrewProebstelDrew Proebstel
andauthored
create counter and deleter service (#6143)
Co-authored-by: Drew Proebstel <[email protected]>
1 parent 535f4e9 commit 201281f

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# frozen_string_literal: true
2+
3+
module StateFile
4+
class Ty24DeleteService
5+
INTAKE_MAP = StateFile::Ty24ArchiverService::INTAKE_MAP
6+
7+
attr_reader :state_code, :intake_class, :tax_year, :start_date, :end_date
8+
9+
def initialize(state_code:)
10+
@state_code = state_code.to_s.downcase
11+
@intake_class = INTAKE_MAP[@state_code.to_sym]
12+
@tax_year = 2024
13+
14+
et = ActiveSupport::TimeZone["America/New_York"]
15+
@start_date = et.parse("2025-01-15 00:00:00")
16+
@end_date = et.parse("2025-10-25 23:59:59")
17+
end
18+
19+
def self.call(state_code:)
20+
new(state_code: state_code).call
21+
end
22+
23+
def call
24+
intake_class
25+
.where(created_at: start_date..end_date)
26+
.in_batches(of: 1000)
27+
.delete_all
28+
end
29+
end
30+
end
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# frozen_string_literal: true
2+
3+
module StateFile
4+
class Ty24ToDeleteCounterService
5+
INTAKE_MAP = StateFile::Ty24ArchiverService::INTAKE_MAP
6+
7+
attr_reader :state_code, :intake_class, :tax_year, :start_date, :end_date
8+
9+
def initialize(state_code:)
10+
@state_code = state_code.to_s.downcase
11+
@intake_class = INTAKE_MAP[@state_code.to_sym]
12+
@tax_year = 2024
13+
14+
et = ActiveSupport::TimeZone["America/New_York"]
15+
@start_date = et.parse("2025-01-15 00:00:00")
16+
@end_date = et.parse("2025-10-25 23:59:59")
17+
end
18+
19+
def self.count(state_code:)
20+
new(state_code: state_code).count
21+
end
22+
23+
def count
24+
intake_class.where(created_at: start_date..end_date).count
25+
end
26+
end
27+
end

0 commit comments

Comments
 (0)