We are trying to upload classification for Omniture report suites with Omniture API. The code runs successfully - A job is created, the job status is checked and a completion is reported.
Relation ID matched - report suite = 'xxxxxxxxxx', relation id = '51', relation name = 'Products'.
Job #4003318 populated. Report Suite ID='xxxxxxxxxx', Data Rows='196', Relation ID='51'.
COMMIT JOB : ID = '4003318', MESSAGE = 'Success'
Job ID = '4003318', time = '2014-01-21 17:19:05.802000', check # = '0', status ='In Progress'
Job ID = '4003318', time = '2014-01-21 17:19:17.224000', check # = '1', status ='In Progress'
Job ID = '4003318', time = '2014-01-21 17:19:28.552000', check # = '2', status ='In Progress'
Job ID = '4003318', time = '2014-01-21 17:19:39.906000', check # = '3', status = 'In Progress'
Job ID = '4003318', time = '2014-01-21 17:19:51.559000', check # = '4', status = 'In Progress'
Job ID = '4003318', time = '2014-01-21 17:20:03.495000', check # = '5', status = 'In Progress - 0% Complete
Job ID = '4003318', time = '2014-01-21 17:20:15.101000', check # = '6', status = 'Completed'
Job ID # '4003318' has finished polling, with a status of 'Completed'.
However, the classification update is not reflected in the reports. It is a completed black box on the other end and we are not able to figure out why it is not showing up in the Omniture front end reports. We are trying to get help from Adobe support, but it has been slow. Any insight is appreciated.
Thanks.
Related
I need to run a script in wrk to test my endpoint. My script is as followed:
thread_counter = 0
local thread_id = 1
setup = function (thread)
thread_counter = thread_counter + 1
thread_id = thread_counter
print("thread_id 1 " ..thread_id)
end
request = function()
idx = math.random(200)
print("thread_id 2 " ..thread_id)
...
end
I can see that thread_id is updated in the setup function, but not the request function. Why and how can I fix this?
I'm trying to build a trial period checker and I'm trying to test whether a user was created inside the 14 day period. So if its outside 14 days then I get a false. Thoughts?
if #user.trial_period === true
trial_users = User.where(created_at:14.days.ago..Time.current.end_of_day)
#trial_check_user = trial_users.where('id = ?', current_user.id)
if #trial_check_user.first.present?
#user_in_trial = true
puts "!!!!!!! USER STILL IN TRIAL WINDOW !!!!!!!".red
else
#user_in_trial = false
puts "!!!!!!! NOT IN TRIAL NEED SUBCRIPTION !!!!!!!".red
redirect_to new_subscription_path
end
if current_user.created_at > 14.days.ago
# Still in trial
#trial_check_users = User.where('created_at > ?', 14.days.ago).count
else
#trial_check = false
redirect_to new_subscription_path
end
I'm having an issue about thread secure variables. I have a controller method which sends sms to given numbers. But if users makes request at the same time variables are being overwritten.
I know RoR s not thread-secure and i have to make it but i couldnt do it with live response. If i would take all data from user and do it in a background job, it would be easier.
For example lets say first user tries to send sms to x number with the content a and the second user tries to send sms y number with the content b. If they make the requests at the exactly same moment x number getting two sms with content a and b.
def create
success = false
message = nil
status = 422
if params[:receivers].present? && params[:title].present? && params[:content].present?
if params[:is_future_sms].present? && params[:is_future_sms].to_s == 'true' && !params[:send_date].present?
render json: {success: false, message: 'Insufficient Parameter'}
else
sms = #account.sms_objects.new(sms_object_params)
sms.sms_title_id = set_sms_title_id
sms.receivers = sms.receivers.to_s
receivers = NumberOperations.sanitize_receivers_with_hash(sms.receivers)
if receivers.count > 0
total_count = sms.credit(sms.content)
sms_balance = sms.balance(sms.content)
receivers.map{|r| r[:balance] = sms_balance}
sms_balance = receivers.count * total_count
if #account.can_afford_sms?(sms_balance)
if sms.save
SendSmsJob.perform_later(sms.id, receivers)
success = true
message = 'Messages created successfully'
status = 201
else
success = false
message = sms.errors.full_messages.to_sentence
status = 422
end
else
success = false
message = 'Insufficient Credit'
status = 422
end
else
success = false
message = 'No valid number'
status = 422
end
end
else
success = false
message = 'Insufficient Parameter'
status = 422
end
render json: { success: success, message: message }, status: status
end
I guess i can solve the problem with mutex and Thread.new but when i use it it doesnt give the response to user.
def create
th = Thread.new do
# all code here
end
th.join
end
this works well but doesnt response at the end.
Yeyyy! I found the solution.
I've changed my server from puma to unicorn. And it works properly now.
I'm pretty new to Ruby scripting and have made a script to loop through product collections in Shopify to change the 'product match condition' on all collections but I can't seem to get it to work at all unless I specify the collection ID.
I keep getting an error saying "NoMethodError: undefined method `disjunctive=' for #" and I can't figure out why. The script I've written is below:
Failed collection loop:
count = ShopifyAPI::SmartCollection.count
page = 1
while count > 0
collectionsEdits = ShopifyAPI::SmartCollection.find(:all,:params => {:page=> page})
collectionsEdits.disjunctive = 'true'
collectionsEdits.save
count = count - 50
page = page + 1
end
Specific collection ID:
collectionUpdate = ShopifyAPI::SmartCollection.find(437592964)
collectionUpdate.disjunctive = 'true'
collectionUpdate.save
Any help would be greatly appreciated!
API Documentation: https://help.shopify.com/api/reference/smartcollection
if Shopify::SmartCollection is just an ActiveRecord model so I'd recommend you to write that like this:
ShopifyAPI::SmartCollection.where(page: page).update_all(disjunctive: 'true')
P.S. in where clause you could provide any hash with your conditions
In your case error occurs because find(:all) return a collection but not a single instance that's why you cannot execute disjunctive = 'true'
So if you still want to write that your way do it like this:
count = ShopifyAPI::SmartCollection.count
page = 1
while count > 0
collectionsEdits = ShopifyAPI::SmartCollection.find(:all,:params => {:page=> page})
collectionEdits.each do |collectionEdit|
collectionEdit.disjunctive = 'true'
collectionEdit.save
end
count = count - 50
page = page + 1
end
I seem to be having trouble with both RPush and Houston.
Here's more or less what my controller looks like...
def create
if authenticate_user
post = Post.find_by_id(params[:post_id])
if post
comment = post.comments.new(comment_params.merge(user_id: params[:user_id]))
Comment.transaction do
if (comment.save)
apns_file = File.join(Rails.root, "APNSCert.pem")
app = Rpush::Apns::App.new
app.name = "My App"
app.certificate = File.read(apns_file)
app.environment = "sandbox" # APNs environment.
app.password = ENV["apns_certificate_password"] #figaro
app.connections = 1
app.save!
#SEND Push notification to the user who made the original post
post_user = User.find(post.user_id)
comment_user = User.find(comment.user_id)
if post_user && comment_user
rememeber_tokens_for_user = RememberToken.where("user_id = ?", post_user.id)
if rememeber_tokens_for_user.size > 0
rememeber_tokens_for_user.each do |remember_token|
# Create a notification that alerts a message to the user, plays a sound, and sets the badge on the app
alert = comment_user.name + ": " + comment.comment_text
if alert.length > 50
alert = alert[0..46] + "..."
end
n = Rpush::Apns::Notification.new
n.app = Rpush::Apns::App.find_by_name("My App")
n.device_token = remember_token.device_token
n.alert = alert
n.data = { foo: "bar" }
n.save!
It appears my server on heroku is getting an error on the app.save! line, ActiveRecord::RecordInvalid (Validation failed: Name has already been taken):.
I'm no more than an intermediate in rails, so any help would be appreciated. Am I suppose to put the 'app' variable section of code into a separate class that is somehow only called once or something, similar to a singleton in objective-c? It apparently doesn't like when it's accessed by a different user POSTing to this resource, which is when I get this error.
Should I take a stab at Grocer, since I can't seem to get Houston or RPush working?
You definitely do not need to do the APN setup more than once per app. That's exactly why you're having the problem.
Insert a check to create an app only when there is not one already created:
if !Rpush::Gcm::App.find_by_name("My App")
app.name = "My App"
app.certificate = File.read(apns_file)
app.environment = "sandbox" # APNs environment.
app.password = ENV["apns_certificate_password"] #figaro
app.connections = 1
app.save!
end