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
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/nexmo_developer/db/migrate/20180403111850_add_product_to_feedback_resources.rb', line 2
def up
add_column :feedback_resources, :product, :string
add_index :feedback_resources, :product
products = [
'voice/sip',
'voice/voice-api',
'messaging/sms',
'messaging/conversion-api',
'messaging/sns',
'messaging/us-short-codes',
'verify',
'number-insight',
'account',
'concepts',
'stitch/in-app-voice',
'stitch/in-app-messaging',
'messages-and-workflows-apis/messages',
'messages-and-workflows-apis/workflows',
]
Feedback::Resource.all.each do |feedback_resource|
uri = URI(feedback_resource.uri)
product = products.detect do |product|
break product if uri.path.start_with? "/#{product}"
end
next unless product
feedback_resource.update({
product: product,
})
end
end
|