Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Patricio Sanchez
/
quiniela-mundial
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Iker Narvaez
2018-06-12 10:06:51 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f243e316eb8dfed809f3ee6506951e125f9d72f4
f243e316
1 parent
f08d7f7d
dashboard changes
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
73 additions
and
41 deletions
app/assets/stylesheets/root.scss
app/controllers/application_controller.rb
app/controllers/my_profile_controller.rb
app/views/application/_leaderboard.html.slim
app/views/application/_results.html.slim
app/views/application/_upcoming_matches.html.slim
app/views/application/leaderboard.html.slim
app/views/bets/_readonly_pool.slim
config/routes.rb
app/assets/stylesheets/root.scss
View file @
f243e31
...
...
@@ -73,7 +73,8 @@ table {
.upcoming
{
td
{
width
:
33%
;
width
:
25%
;
font-size
:
12px
;
}
}
...
...
@@ -94,9 +95,9 @@ table {
text-align
:
left
;
}
td
,
th
{
width
:
50%
;
}
//
td, th {
// //
width: 50%;
//
}
}
// Bets
...
...
@@ -182,3 +183,15 @@ input[type="submit"] {
max-width
:
70vw
;
}
}
.vs-cell
{
width
:
40px
;
}
.text-left
{
text-align
:
left
;
width
:
100%
;
}
td
.points
{
font-weight
:
700
;
&
.zero
{
color
:
red
}
&
.positive
{
color
:
green
}
}
...
...
app/controllers/application_controller.rb
View file @
f243e31
...
...
@@ -2,15 +2,20 @@ class ApplicationController < HeimdallEngine::ApplicationController
protect_from_forgery
with: :exception
def
root
leaderboard
l
oad_l
eaderboard
check_matches
recent_matches
@results
=
check_results
end
def
leaderboard
@leaders
=
Bet
.
joins
(
:user
).
group
(
'users.name'
).
sum
(
:points
)
.
sort_by
{
|
k
,
v
|
v
}
end
private
def
leaderboard
def
l
oad_l
eaderboard
@leaders
=
Bet
.
joins
(
:user
).
group
(
'users.name'
).
sum
(
:points
)
.
sort_by
{
|
k
,
v
|
v
}.
take
(
5
)
end
...
...
@@ -28,7 +33,7 @@ class ApplicationController < HeimdallEngine::ApplicationController
def
check_results
return
[]
unless
current_user
current_user
.
bets
.
joins
(
:match
).
order
(
'matches.date desc'
)
.
where
.
not
(
result
:
nil
)
.
where
.
not
(
points
:
nil
)
.
limit
(
5
)
end
end
...
...
app/controllers/my_profile_controller.rb
0 → 100644
View file @
f243e31
class
MyProfileController
<
CrudController
::
Base
enable_gatekeeper
private
def
object_params
params
.
require
(
:user
).
permit
(
:name
,
:mail
,
:password
,
:password_confirmation
)
end
end
app/views/application/_leaderboard.html.slim
View file @
f243e31
h1
Leaderboard
table
.leaderboard
tbody
-
@leaders
.
each
do
|
group_name
,
data
|
-
@leaders
.
each
.
with_index
do
|
(
user_name
,
points
),
i
|
tr
td
colspan
=
2
=
group_name
-
data
[
:leaderboard
].
each
do
|
user_name
,
points
|
t
r
td
=
user_name
td
=
points
-
if
data
[
:leaderboard
].
empty?
tr
td
colspan
=
2
There
are
no
results
yet
td
style
=
'width: 50px'
=
1
+
i
td
=
user_name
t
d
=
points
-
if
@leaders
.
empty?
tr
td
colspan
=
2
There
are
no
results
yet
.text-left
style
=
'margin-top: 10px;'
=
link_to
'See everyone'
,
leaderboard_path
...
...
app/views/application/_results.html.slim
View file @
f243e31
...
...
@@ -6,7 +6,7 @@ table
td
=
r
.
match
.
local
td
VS
td
=
r
.
match
.
visit
td
=
r
.
points
td
.points
class
=
"#{r.points.to_i.zero? ? 'zero' : 'positive'}"
=
r
.
points
-
if
@results
.
empty?
tr
td
colspan
=
4
There
are
no
finished
matches
yet
.
...
...
app/views/application/_upcoming_matches.html.slim
View file @
f243e31
...
...
@@ -5,19 +5,6 @@ table.upcoming
tr
td
=
l
(
u
.
date
,
format: :short
)
td
=
u
.
local
td
VS
td
.vs-cell
VS
td
=
u
.
visit
h1
Recent
matches
table
.recent
tbody
-
@recent_matches
.
each
do
|
match
|
tr
td
=
l
(
match
.
date
,
format: :short
)
td
=
match
.
local
td
=
match
.
score_local
td
=
match
.
visit
td
=
match
.
score_visit
-
if
@recent_matches
.
empty?
tr
td
colspan
=
4
There
are
no
finished
matches
yet
.
...
...
app/views/application/leaderboard.html.slim
0 → 100644
View file @
f243e31
.middle.content
h1
Leaderboard
table
.leaderboard
tbody
-
@leaders
.
each
.
with_index
do
|
(
user_name
,
points
),
i
|
tr
td
style
=
'width: 50px'
=
1
+
i
td
=
user_name
td
=
points
-
if
@leaders
.
empty?
tr
td
colspan
=
2
There
are
no
results
yet
.text-left
style
=
'margin-top: 10px;'
=
link_to
'Back'
,
root_path
app/views/bets/_readonly_pool.slim
View file @
f243e31
table
thead
th
Day
th
Home
th
Your
bet
th
Away
th
Your
bet
th
Result
th
Home
Score
th
Away
Score
th
Points
th
style
=
'text-align: left'
Day
th
style
=
'text-align: left'
Home
th
style
=
'text-align: left'
Your
bet
th
style
=
'text-align: left'
Away
th
style
=
'text-align: left'
Your
bet
th
style
=
'text-align: left'
Result
th
style
=
'text-align: left'
Home
Score
th
style
=
'text-align: left'
Away
Score
th
style
=
'text-align: left'
Points
-
pool
.
matches
.
each
do
|
match
|
-
bet
=
current_user
.
bets
.
find_or_initialize_by
(
match_id:
match
.
id
)
tr
...
...
@@ -20,5 +20,5 @@ table
td
=
match
.
result
?
match
.
result
.
upcase
:
'PENDING'
td
=
match
.
score_local
td
=
match
.
score_visit
td
=
bet
.
try
(
:points
)
td
.points
class
=
"#{bet.points.to_i.zero? ? 'zero' : 'positive'}"
=
bet
.
try
(
:points
)
...
...
config/routes.rb
View file @
f243e31
...
...
@@ -2,6 +2,7 @@ Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
HeimdallEngine
.
load_routes
root
'application#root'
get
'leaderboard'
,
to:
'application#leaderboard'
,
as: :leaderboard
resources
:bets
,
only:
[
:index
]
do
collection
do
patch
:update
,
as: :put
...
...
Please
register
or
login
to post a comment