summaryrefslogtreecommitdiff
path: root/app/services/namespaces/in_product_marketing_email_records.rb
blob: 1237a05ea133abf202bbfb7615f6582feab2d279 (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
# frozen_string_literal: true

module Namespaces
  class InProductMarketingEmailRecords
    attr_reader :records

    def initialize
      @records = []
    end

    def save!
      Users::InProductMarketingEmail.bulk_insert!(@records)
      @records = []
    end

    def add(user, track, series)
      @records << Users::InProductMarketingEmail.new(
        user: user,
        track: track,
        series: series,
        created_at: Time.zone.now,
        updated_at: Time.zone.now
      )
    end
  end
end