Skip to content

Commit 5a6cd49

Browse files
committed
Added logic for zero stats
1 parent 73b3780 commit 5a6cd49

File tree

2 files changed

+51
-42
lines changed

2 files changed

+51
-42
lines changed

app/presenters/user_presenter.rb

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,51 @@ def initialize(user)
77
end
88

99
def repos
10-
user.repos.gsub("\"","").split(", ")[2..-2]
10+
if user.repos == "[]"
11+
["You have no repositories!"]
12+
else
13+
user.repos.gsub("\"","").split(", ")[2..-2]
14+
end
1115
end
1216

1317
def starred_repos
14-
user.starred_repos
18+
if user.starred_repos == "[]"
19+
["You have no starred repositories!"]
20+
else
21+
user.starred_repos
22+
end
1523
end
1624

1725
def commit_mess
18-
user.commit_messages.gsub("\"","").split(", ")[2..-2]
26+
if user.commit_messages == "[]"
27+
["You have no commit messages"]
28+
else
29+
user.commit_messages.gsub("\"","").split(", ")[2..-2]
30+
end
1931
end
2032

2133
def organizations
22-
user.organizations.gsub("\"","").split(", ")[2..-2]
34+
if user.organizations == "[]"
35+
["You have no organizations!"]
36+
else
37+
user.organizations.gsub("\"","").split(", ")[2..-2]
38+
end
2339
end
2440

2541
def followers
26-
user.followers.gsub("\"","").split(", ")[2..-2]
42+
if user.followers == "[]"
43+
["You have no followers LOSER!"]
44+
else
45+
user.followers.gsub("\"","").split(", ")[2..-2]
46+
end
2747
end
2848

2949
def followees
30-
user.followees.gsub("\"","").split(", ")[2..-2]
50+
if user.followees == "[]"
51+
["You are not following anyone!"]
52+
else
53+
user.followees.gsub("\"","").split(", ")[2..-2]
54+
end
3155
end
3256

3357
def year_commits
@@ -43,6 +67,10 @@ def longest_streaks
4367
end
4468

4569
def followers_activities
46-
user.follower_messages.gsub("\"","").gsub("\\","").gsub("{","").gsub("}","").split(", ")
70+
if user.follower_messages == "[]"
71+
["None of your friends are coding"]
72+
else
73+
user.follower_messages.gsub("\"","").gsub("\\","").gsub("{","").gsub("}","").split(", ")
74+
end
4775
end
4876
end

app/views/dashboard/show.html.erb

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,28 @@
2727

2828
<div class="col-md-4">
2929
<h3 class="home">Your Repositories</h3>
30-
<h4 class="home"><%= pluralize(@user_info.repos.count, 'Repository') %></h4>
3130
<br>
3231
<ol>
33-
<% @user_info.repos.each do |repo| %>
34-
<li class="home"><%= repo %></li>
35-
<% end %>
36-
</ol>
32+
<% @user_info.repos.each do |repo| %>
33+
<p class="home"><%= repo %></p>
34+
<% end %>
3735
</div>
3836

3937
<div class="col-md-4">
4038
<h3 class="home">Your Followers</h3>
41-
<h4 class="home"><%= pluralize(@user_info.followers.count, 'person') %> are following you</h4>
4239
<br>
43-
<ol>
44-
<% @user_info.followers.each do |follower| %>
45-
<li class="home"><%= follower %></li>
40+
<% @user_info.followers.each do |follower| %>
41+
<p class="home"><%= follower %></p>
4642
<% end %>
47-
</ol>
43+
4844
</div>
4945

5046
<div class="col-md-4">
5147
<h3 class="home">Who You are Following?</h3>
52-
<h4 class="home">You are following <%= pluralize(@user_info.followees.count, 'person') %></h4>
5348
<br>
54-
<ol>
55-
<% @user_info.followees.each do |followee| %>
56-
<li class="home"><%= followee %></li>
49+
<% @user_info.followees.each do |followee| %>
50+
<p class="home"><%= followee %></p>
5751
<% end %>
58-
</ol>
5952
</div>
6053

6154
</div>
@@ -65,37 +58,25 @@
6558
<div class="row">
6659

6760
<div class="col-md-4">
68-
6961
<h3 class="home">Your Organizations</h3>
70-
<h4 class="home"><%= pluralize(@info.organizations.count, 'Organization') %></h4>
7162
<br>
72-
<% if @user_info.organizations.nil? %>
73-
<p class="home">You have no organizations!</p>
74-
<% else %>
75-
<ol>
76-
<% @user_info.organizations.each do |org| %>
77-
<li class="home"><%= org %></li>
78-
<% end %>
79-
</ol>
63+
<% @user_info.organizations.each do |org| %>
64+
<p class="home"><%= org %></p>
8065
<% end %>
8166
</div>
8267

8368
<div class="col-md-4">
8469
<h3 class="home">Your Recent Commit Messages</h3>
85-
<ol>
86-
<% @user_info.commit_mess.each do |message| %>
87-
<li class="home"><%= message %></li>
88-
<% end %>
89-
</ol>
70+
<% @user_info.commit_mess.each do |message| %>
71+
<p class="home"><%= message %></p>
72+
<% end %>
9073
</div>
9174

9275
<div class="col-md-4">
9376
<h3 class="home">Summary Feed of my Followers</h3>
94-
<ol>
95-
<% @user_info.followers_activities.each do |activity| %>
96-
<li class="home"><%= activity %></li>
97-
<% end %>
98-
</ol>
77+
<% @user_info.followers_activities.each do |activity| %>
78+
<p class="home"><%= activity %></p>
79+
<% end %>
9980
</div>
10081

10182
</div>

0 commit comments

Comments
 (0)