Skip to content

Commit ebbbcd8

Browse files
author
joeltaylor
committed
Add lastDay to
1 parent e0de7f5 commit ebbbcd8

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

routes/news.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ router.
128128
if (offset) {
129129
Articles.paginated(offset, function(all) {
130130
Articles.totalPublished(function(total) {
131-
131+
var lastDay;
132132
// TODO: Move date functionality into a serivce. It'll be used practically
133133
// everywhere. Oh, and refactor this blasphemy.
134134
//
@@ -146,15 +146,16 @@ router.
146146
}
147147
});
148148
// There are strings and integers here - not so good.
149+
lastDay = all[all.length - 1].date;
149150
more = (all.length == (total[0].count - offset )) ? false : true;
150151
all = _.groupBy(all, 'date');
151-
res.json({flow: all, more: more});
152+
res.json({flow: all, more: more, lastDay: lastDay});
152153
});
153154
});
154155
}else{
155156
Articles.recent(function(all) {
156157
Articles.totalPublished(function(total) {
157-
var flow = [], news = [];
158+
var flow = [], news = [], lastDay;
158159
// TODO: Move date functionality into a serivce. It'll be used practically
159160
// everywhere. Oh, and refactor this blasphemy.
160161
//
@@ -176,9 +177,10 @@ router.
176177
flow.push(item);
177178
}
178179
});
180+
lastDay = flow[flow.length - 1].date;
179181
more = (flow.length === parseInt(total[0].count)) ? false : true;
180182
flow = _.groupBy(flow, 'date');
181-
res.render('news/index', {flow_collection: flow, news_collection: news, more: more });
183+
res.render('news/index', {flow_collection: flow, news_collection: news, more: more, lastDay: lastDay });
182184
});
183185
});
184186
}

0 commit comments

Comments
 (0)