Collection doesnt sort in the right order on Galaxy server, but works on local server


#1

On the main page, the collection of posts, or “patterns”, are sorted in order by submission.
http://www.subpattern.com/

When you click on the link in the navbar, ‘sort’, then ‘sbp’. It is suppose to by sorted in the order we call “subpatterns”. Right now the pattern with the highest subpatterns has the title “Ubuntu Studio Download”, but instead the app orders in an odd with the first pattern titled “Kids MGMT”.

http://www.subpattern.com/sbp

when you click on this link, refresh, or click on the link coming from a pattern page, it sorts in the correct order, with the patterns with the highest subpatterns ordered first.

the problem only happens going from the main page to the ‘sbp’ page.

The app works perfectly on my local machine. The app live on a Galaxy server, does not sort the collections properly. so its incredibly hard to trouble shoot. Also sometimes when you go from one part of the app to the homepage, the patterns are not sorted correctly.

A temporary solution would be to automatically refresh the page everytime the page is loaded. Does anyone know how to do that?

Below is not my complete router, but the router for that part of the app.

`Router.configure({
layoutTemplate: ‘layout’,
loadingTemplate: ‘loading’,
//waitOn: function() { return Meteor.subscribe(‘patterns’); }
});

Router.plugin(“dataNotFound”,{
notFoundTemplate: “dataNotFound”
})

PatternsListController = RouteController.extend({
template: ‘main’,
increment: 15,
postsLimit: function() {
return parseInt(this.params.postsLimit) || this.increment;
},
findOptions: function() {
return {sort: this.sort, limit: this.postsLimit()};
},
subscriptions: function() {
this.postsSub = Meteor.subscribe(‘patterns’, this.findOptions());
},
patterns: function() {
return Patterns.find({}, this.findOptions());
},
data: function() {
var self = this;
return {
patterns: self.patterns(),
ready: self.postsSub.ready,
nextPath: function() {
if (self.patterns().count() === self.postsLimit())
return self.nextPath();
}
};
}
});

NewPatternsListController = PatternsListController.extend({
template: ‘main’,
sort: {submitted: -1, _id: -1, subpatternsCount: -1, votes: -1, commentsCount: -1},
nextPath: function() {
return Router.routes.newPatterns.path({postsLimit: this.postsLimit() + this.increment})
}
});

TopPatternsListController = PatternsListController.extend({
template: ‘mainTop’,
sort: {votes: -1, subpatternsCount: -1, commentsCount: -1, submitted: -1, _id: -1},
nextPath: function() {
return Router.routes.topPatterns.path({postsLimit: this.postsLimit() + this.increment})
}
});

SubPatternsListController = PatternsListController.extend({
template: ‘mainSBP’,
sort: {subpatternsCount: -1, votes: -1, commentsCount: -1, submitted: -1, _id: -1},
nextPath: function() {
return Router.routes.newPatterns.path({postsLimit: this.postsLimit() + this.increment})
}
});

CommentsPatternsListController = PatternsListController.extend({
template: ‘mainCMNT’,
sort: {commentsCount: -1, subpatternsCount: -1, votes: -1, submitted: -1, _id: -1},
nextPath: function() {
return Router.routes.cmntsPatterns.path({postsLimit: this.postsLimit() + this.increment})
}
});

Router.route(‘main’, {
path: ‘/’,
controller: NewPatternsListController
});

Router.route(‘newPatterns’, {
path: ‘/new/:postsLimit?’,
controller: NewPatternsListController
});

Router.route(‘topPatterns’, {
path: ‘/top/:postsLimit?’,
controller: TopPatternsListController
});

Router.route(‘subPatterns’, {
path: ‘/sbp/:postsLimit?’,
controller: SubPatternsListController
});

Router.route(‘cmntsPatterns’, {
path: ‘/cmnts/:postsLimit?’,
controller: CommentsPatternsListController
});`


#2

document.location.reload(true);

this refreshes the page. just dont know how to use it properly.


#3

Router.route(‘subPatterns’, {
path: ‘/sbp/:postsLimit?’,
controller: SubPatternsListController
},
function () {
document.location.reload(true);
}
);

changed all my routes to look like this. Galaxy doesnt deployinsatntly, so will have to come back and see if this solution worked.