Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
f5407fdb
Commit
f5407fdb
authored
Aug 10, 2020
by
Robert Czechowski
Browse files
Dump list of participations to profile template with information about timeleft
parent
67629a1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/core.rs
View file @
f5407fdb
...
...
@@ -873,9 +873,17 @@ pub fn show_profile<T: MedalConnection>(conn: &T, session_token: &str, user_id:
}
}
let
now
=
time
::
get_time
();
// TODO: Needs to be filtered
let
participations
:
Vec
<
(
i32
,
String
)
>
=
conn
.get_all_participations_complete
(
session
.id
)
.into_iter
()
.map
(|(
_participation
,
contest
)|
(
contest
.id
.unwrap
(),
contest
.name
))
.collect
();
data
.insert
(
"ownparticipations"
.into
(),
to_json
(
&
participations
));
let
participations
:
Vec
<
(
i32
,
String
,
bool
,
bool
)
>
=
conn
.get_all_participations_complete
(
session
.id
)
.into_iter
()
.rev
()
.map
(|(
participation
,
contest
)|
{
let
passed_secs
=
now
.sec
-
participation
.start.sec
;
let
left_secs
=
i64
::
from
(
contest
.duration
)
*
60
-
passed_secs
;
let
is_time_left
=
contest
.duration
==
0
||
left_secs
>=
0
;
let
has_timelimit
=
contest
.duration
!=
0
;
(
contest
.id
.unwrap
(),
contest
.name
,
has_timelimit
,
is_time_left
)
})
.collect
();
data
.insert
(
"participations"
.into
(),
to_json
(
&
participations
));
}
Some
(
user_id
)
=>
{
// TODO: Add test to check if this access restriction works
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment