TRIVIAL: fix deprecations due to momentjs upgrade

This commit is contained in:
Régis Hanol 2014-08-20 22:22:58 +02:00
parent 33de48dc0c
commit 5b1785157d
7 changed files with 17 additions and 17 deletions

View file

@ -12,7 +12,7 @@ Discourse.EmailPreview.reopenClass({
findDigest: function(lastSeenAt) {
if (Em.isEmpty(lastSeenAt)) {
lastSeenAt = moment().subtract('days',7).format('YYYY-MM-DD');
lastSeenAt = moment().subtract(7, 'days').format('YYYY-MM-DD');
}
return Discourse.ajax("/admin/email/preview-digest.json", {

View file

@ -5,7 +5,7 @@ Discourse.Report = Discourse.Model.extend({
valueAt: function(numDaysAgo) {
if (this.data) {
var wantedDate = moment().subtract('days', numDaysAgo).format('YYYY-MM-DD');
var wantedDate = moment().subtract(numDaysAgo, 'days').format('YYYY-MM-DD');
var item = this.data.find( function(d) { return d.x === wantedDate; } );
if (item) {
return item.y;
@ -16,8 +16,8 @@ Discourse.Report = Discourse.Model.extend({
sumDays: function(startDaysAgo, endDaysAgo) {
if (this.data) {
var earliestDate = moment().subtract('days', endDaysAgo).startOf('day');
var latestDate = moment().subtract('days',startDaysAgo).startOf('day');
var earliestDate = moment().subtract(endDaysAgo, 'days').startOf('day');
var latestDate = moment().subtract(startDaysAgo, 'days').startOf('day');
var d, sum = 0;
_.each(this.data,function(datum){
d = moment(datum.x);

View file

@ -15,7 +15,7 @@ export default Discourse.Route.extend({
},
fetchDashboardData: function(c) {
if( !c.get('dashboardFetchedAt') || moment().subtract('minutes', 30).toDate() > c.get('dashboardFetchedAt') ) {
if( !c.get('dashboardFetchedAt') || moment().subtract(30, 'minutes').toDate() > c.get('dashboardFetchedAt') ) {
c.set('dashboardFetchedAt', new Date());
Discourse.AdminDashboard.find().then(function(d) {
if( Discourse.SiteSettings.version_checks ){
@ -41,14 +41,14 @@ export default Discourse.Route.extend({
});
}
if( !c.get('problemsFetchedAt') || moment().subtract('minute',c.problemsCheckMinutes).toDate() > c.get('problemsFetchedAt') ) {
if( !c.get('problemsFetchedAt') || moment().subtract(c.problemsCheckMinutes, 'minutes').toDate() > c.get('problemsFetchedAt') ) {
c.set('problemsFetchedAt', new Date());
c.loadProblems();
}
},
fetchGithubCommits: function(c) {
if( !c.get('commitsCheckedAt') || moment().subtract('hour',1).toDate() > c.get('commitsCheckedAt') ) {
if( !c.get('commitsCheckedAt') || moment().subtract(1, 'hour').toDate() > c.get('commitsCheckedAt') ) {
c.set('commitsCheckedAt', new Date());
c.set('githubCommits', Discourse.GithubCommit.findAll());
}

View file

@ -17,7 +17,7 @@ Discourse.AdminEmailPreviewDigestRoute = Discourse.Route.extend({
var controller = this.controllerFor('adminEmailPreviewDigest');
controller.setProperties({
model: model,
lastSeen: moment().subtract('days',7).format('YYYY-MM-DD'),
lastSeen: moment().subtract(7, 'days').format('YYYY-MM-DD'),
showHtml: true
});
}

View file

@ -29,7 +29,7 @@ var formatDays = function(days) {
};
var shortDate = function(days){
return moment().subtract('days', days).format('D MMM');
return moment().subtract(days, 'days').format('D MMM');
};
test("formating medium length dates", function() {
@ -40,7 +40,7 @@ test("formating medium length dates", function() {
};
var shortDateYear = function(days){
return moment().subtract('days', days).format('D MMM YYYY');
return moment().subtract(days, 'days').format('D MMM YYYY');
};
leaveAgo = true;
@ -81,7 +81,7 @@ test("formating medium length dates", function() {
test("formating tiny dates", function() {
var shortDateYear = function(days){
return moment().subtract('days', days).format("MMM 'YY");
return moment().subtract(days, 'days').format("MMM 'YY");
};
format = "tiny";
@ -144,7 +144,7 @@ test("formating tiny dates", function() {
module("Discourse.Formatter");
test("autoUpdatingRelativeAge", function() {
var d = moment().subtract('days',1).toDate();
var d = moment().subtract(1, 'day').toDate();
var $elem = $(Discourse.Formatter.autoUpdatingRelativeAge(d));
equal($elem.data('format'), "tiny");

View file

@ -4,7 +4,7 @@ function reportWithData(data) {
return Discourse.Report.create({
type: 'topics',
data: _.map(data, function(val, index) {
return {x: moment().subtract("days", index).format('YYYY-MM-DD'), y: val};
return { x: moment().subtract(index, "days").format('YYYY-MM-DD'), y: val };
})
});
}

View file

@ -5,14 +5,14 @@ test('dataIsOld', function() {
equal(Discourse.VersionCheck.create(args).get('dataIsOld'), expected, message);
};
dataIsOld({updated_at: moment().subtract('hours', 2).toJSON()}, false, '2 hours ago');
dataIsOld({updated_at: moment().subtract('hours', 49).toJSON()}, true, '49 hours ago');
dataIsOld({updated_at: moment().subtract('hours', 2).toJSON(), version_check_pending: true}, true, 'version check pending');
dataIsOld({updated_at: moment().subtract(2, 'hours').toJSON()}, false, '2 hours ago');
dataIsOld({updated_at: moment().subtract(49, 'hours').toJSON()}, true, '49 hours ago');
dataIsOld({updated_at: moment().subtract(2, 'hours').toJSON(), version_check_pending: true}, true, 'version check pending');
});
test('staleData', function() {
var updatedAt = function(hoursAgo) {
return moment().subtract('hours', hoursAgo).toJSON();
return moment().subtract(hoursAgo, 'hours').toJSON();
};
var staleData = function(args, expected, message) {
equal(Discourse.VersionCheck.create(args).get('staleData'), expected, message);