8000 Show names of who voted for projects on finalist page. by kaunartist · Pull Request #144 · awesomefoundation/awesomebits · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Show names of who voted for projects on finalist page. #144

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ def self.by_vote_count
order("vote_count DESC")
end

def vote_names
names = "";
users.each_with_index do |user, index|
names << user.name
if index != users.size - 1
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd prefer an array of names here, and then we can render it as arr.join(", ") in the view.

names << ", "
end
end
return names
end

def self.recent_winners
subquery = select("DISTINCT ON (chapter_id) projects.*").where("projects.funded_on IS NOT NULL").order(:chapter_id, :funded_on).reverse_order
select("*").from("(#{subquery.to_sql}) AS distinct_chapters").order(:funded_on).reverse_order
Expand Down
2 changes: 2 additions & 0 deletions app/views/finalists/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
<th><%= t ".table.title" %></th>
<th><%= t ".table.id " %></th>
<th><%= t ".table.votes" %></th>
<th>Who voted?</th>
Copy link
Member

Choose a reason for hiding this comment

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

This should be added to the en.yml file, not hard-coded into the view.

</tr>
<% @projects.each do |project| %>
<tr class="finalist" data-count="<%= project.vote_count %>" data-id="<%= project.id %>">
<td><%= link_to project.title, chapter_project_path(project.chapter, project) %></td>
<td><%= project.id %></td>
<td><%= project.vote_count %></td>
<td><%= project.vote_names %></td>
Copy link
Member

Choose a reason for hiding this comment

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

This is going to get super heavy on a page with a lot of projects, so we probably want to do some eager loading on the page that loads the projects.

</tr>
<% end %>
</table>
Expand Down
0