Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corrected month calculation #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SwethaMuralidharan
Copy link

#4 Explanation

  1. Since the issue is with archives, visited archives view file (_content.html.erb).
  2. There was a link_to year and month in that file.
  3. Checked where that year and month is getting computed and found it in the model file.
    (archives_sidebar.rb)
  4. Month number is calculated wrongly in archives_sidebar.rb file as (month % 12)+1 in parse
    method.
  5. Changed that as month = (entry.month.to_i) || 12 and it worked. This made the months also to be
    sorted which fixes the issue Months sorted incorrectly (Archive Sidebar) #5

@@ -0,0 +1 @@
continue
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change here?

@@ -30,7 +30,7 @@ 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this had to be or'd with the number 12?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants