Last active
February 17, 2021 08:24
-
-
Save Unayung/67eda094f4aeb5d83c484ff018d7d98c to your computer and use it in GitHub Desktop.
rand histories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rand_source | |
a = ['line', 'fb', 'ettoday', 'nonews', 'cti', 'momo', '7-11'] | |
a[rand(7)] | |
end | |
def rand_campaign | |
a = ['0923-加入會員', nil, '年中大促', '週年慶九折', '1111', '1212', '跳樓大拍賣'] | |
a[rand(7)] | |
end | |
def rand_medium | |
a = ['banner', 'welcome', nil, 'sidebar', 'ad', 'footer', 'pchome-sidebar-ad-0122'] | |
a[rand(7)] | |
end | |
def rand_context | |
"{:locale=>\"zh-TW\", :page=>{:path=>\"/\", :referrer=>\"\", :search=>\"\", :title=>\"Insight\", :url=>\"https://cdp.stratevision.com/\"}, :os=>\"MacOS\", :userAgent=>\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36\"}" | |
end | |
def rand_category | |
a = ['page', 'track'] | |
a[rand(2)] | |
end | |
def rand_type | |
a = ['Page', 'Track'] | |
a[rand(2)] | |
end | |
c = Crm.first | |
1000.times do | |
type = rand_type | |
c.histories.create(member_id: 1, type: type, category: type.downcase, utm_source: rand_source, utm_campaign: rand_campaign, utm_medium: rand_medium, context: rand_context, received_at: Time.zone.now) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment