Meteor.startup(function() {
var relatedContents = RelatedContent.find().fetch();
console.log(relatedContents);
for (var index in relatedContents) {
var relatedContent = relatedContents[index];
(function(relatedContent) {
var media = "";
var image_url_relative = "", mediaRelative = "", image_url = "";
if(relatedContent["mediaType"]=="url")
{
image_url = relatedContent["image_url"];
if(image_url && image_url.indexOf("s3-us-west-2.amazonaws.com/"))
{
//var i = image_url.indexOf("s3-us-west-2.amazonaws.com/ibmgo/");
image_url = image_url.replace('ibmgo-images', 'ibmgo');
image_url_relative = image_url.replace('http://s3-us-west-2.amazonaws.com/ibmgo', '/static');
}
else
{
image_url_relative = image_url;
}
}
if(relatedContent["mediaType"]!="url")
{
// if(media.indexOf("s3-us-west-2.amazonaws.com/"))
// {
// var media = relatedContent[media];
// media = media.replace('ibmgo-images', 'ibmgo');
// mediaRelative = media.replace('http://s3-us-west-2.amazonaws.com/ibmgo', '/static');
// }
mediaRelative = relatedContent["mediaRelative"];
if(mediaRelative.indexOf("/static") != -1)
{
media = mediaRelative.replace('/static','http://s3-us-west-2.amazonaws.com/ibmgo');
}
}
RelatedContent.update({
'_id': relatedContent["_id"]
}, {
$set: {
"image_url": image_url,
"image_url_relative": image_url_relative,
"media": media,
"mediaRelative": mediaRelative
}
});
})(relatedContent);
}
});