Skip to content

Commit

Permalink
fixed issue sf-wdi-25#2 :part one
Browse files Browse the repository at this point in the history
  • Loading branch information
rchrzo committed Feb 5, 2016
1 parent 7d8abe4 commit 1a34151
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<% sidebar.archives.each do |month| %>
<% counter = sidebar.show_count ? "<em>(#{month[:article_count]})</em>" : "" %>
<li>
<%= link_to"#{month[:name]} #{counter}".html_safe, articles_by_month_path( month[:year], "%02i" % (month[:month]+1) ) %>
<%= link_to"#{month[:name]} #{counter}".html_safe, articles_by_month_path( month[:year], "%02i" % (month[:month]) ) %>
</li>
<% end %>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions lib/archives_sidebar/lib/archives_sidebar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def parse_request(_contents, _params)
article_counts = Content.find_by_sql(["select count(*) as count, #{date_func} from contents where type='Article' and published = ? and published_at < ? group by year,month order by year desc,month desc limit ? ", true, Time.now, count.to_i])

@archives = article_counts.map do |entry|
month = (entry.month.to_i%12)+1
month = (entry.month.to_i%12)
year = entry.year.to_i
{
name: I18n.l(Date.new(year, month), format: '%B %Y'),
month: month - 1,
month: month -1,
year: year,
article_count: entry.count
}
Expand Down

0 comments on commit 1a34151

Please sign in to comment.