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
67371390
Commit
67371390
authored
Jul 07, 2020
by
Robert Czechowski
Browse files
Admin page: Contest export: Export into file: Download file
parent
b3bfcf4d
Changes
5
Hide whitespace changes
Inline
Side-by-side
export/.keep
0 → 100644
View file @
67371390
src/core.rs
View file @
67371390
...
...
@@ -1292,7 +1292,7 @@ pub fn admin_contest_export<T: MedalConnection>(conn: &T, contest_id: i32, sessi
let
contest
=
conn
.export_contest_results_to_file
(
contest_id
,
&
taskgroup_ids
,
filename
);
Ok
(
"blub"
.to_string
())
Ok
(
"blub
.csv
"
.to_string
())
}
#[derive(PartialEq)]
...
...
src/db_conn.base.rs
View file @
67371390
...
...
@@ -809,7 +809,7 @@ impl MedalConnection for Connection {
/* Warning: This function makes no use of rusts type safety. Handle with care when changeing */
fn
export_contest_results_to_file
(
&
self
,
contest_id
:
i32
,
taskgroups
:
&
[(
i32
,
String
)],
filename
:
&
str
)
{
use
std
::
fs
::
OpenOptions
;
let
file
=
OpenOptions
::
new
()
.write
(
true
)
.create
(
true
)
.truncate
(
true
)
.open
(
"foo.txt"
)
.unwrap
();
let
file
=
OpenOptions
::
new
()
.write
(
true
)
.create
(
true
)
.truncate
(
true
)
.open
(
filename
)
.unwrap
();
let
mut
headers
=
vec!
[
"id"
,
"username"
,
"logincode"
,
...
...
@@ -885,6 +885,8 @@ impl MedalConnection for Connection {
for
i
in
20
..
20
+
taskgroups
.len
()
{
points
.push
(
row
.get
::
<
_
,
Option
<
i32
>>
(
i
));
}
// Serialized as several tuples because Serde only supports tuples up to a certain length
// (16 according to https://docs.serde.rs/serde/trait.Deserialize.html)
wtr
.serialize
(((
row
.get
::
<
_
,
i32
>
(
0
),
row
.get
::
<
_
,
Option
<
String
>>
(
1
),
row
.get
::
<
_
,
Option
<
String
>>
(
2
),
...
...
src/db_conn_postgres.rs
View file @
67371390
...
...
@@ -919,7 +919,7 @@ impl MedalConnection for Connection {
/* Warning: This function makes no use of rusts type safety. Handle with care when changeing */
fn
export_contest_results_to_file
(
&
self
,
contest_id
:
i32
,
taskgroups
:
&
[(
i32
,
String
)],
filename
:
&
str
)
{
use
std
::
fs
::
OpenOptions
;
let
file
=
OpenOptions
::
new
()
.write
(
true
)
.create
(
true
)
.truncate
(
true
)
.open
(
"foo.txt"
)
.unwrap
();
let
file
=
OpenOptions
::
new
()
.write
(
true
)
.create
(
true
)
.truncate
(
true
)
.open
(
filename
)
.unwrap
();
let
mut
headers
=
vec!
[
"id"
,
"username"
,
"logincode"
,
...
...
@@ -995,6 +995,8 @@ impl MedalConnection for Connection {
for
i
in
20
..
20
+
taskgroups
.len
()
{
points
.push
(
row
.get
::
<
_
,
Option
<
i32
>>
(
i
));
}
// Serialized as several tuples because Serde only supports tuples up to a certain length
// (16 according to https://docs.serde.rs/serde/trait.Deserialize.html)
wtr
.serialize
(((
row
.get
::
<
_
,
i32
>
(
0
),
row
.get
::
<
_
,
Option
<
String
>>
(
1
),
row
.get
::
<
_
,
Option
<
String
>>
(
2
),
...
...
src/db_conn_sqlite_new.rs
View file @
67371390
...
...
@@ -919,7 +919,7 @@ impl MedalConnection for Connection {
/* Warning: This function makes no use of rusts type safety. Handle with care when changeing */
fn
export_contest_results_to_file
(
&
self
,
contest_id
:
i32
,
taskgroups
:
&
[(
i32
,
String
)],
filename
:
&
str
)
{
use
std
::
fs
::
OpenOptions
;
let
file
=
OpenOptions
::
new
()
.write
(
true
)
.create
(
true
)
.truncate
(
true
)
.open
(
"foo.txt"
)
.unwrap
();
let
file
=
OpenOptions
::
new
()
.write
(
true
)
.create
(
true
)
.truncate
(
true
)
.open
(
filename
)
.unwrap
();
let
mut
headers
=
vec!
[
"id"
,
"username"
,
"logincode"
,
...
...
@@ -995,6 +995,8 @@ impl MedalConnection for Connection {
for
i
in
20
..
20
+
taskgroups
.len
()
{
points
.push
(
row
.get
::
<
_
,
Option
<
i32
>>
(
i
));
}
// Serialized as several tuples because Serde only supports tuples up to a certain length
// (16 according to https://docs.serde.rs/serde/trait.Deserialize.html)
wtr
.serialize
(((
row
.get
::
<
_
,
i32
>
(
0
),
row
.get
::
<
_
,
Option
<
String
>>
(
1
),
row
.get
::
<
_
,
Option
<
String
>>
(
2
),
...
...
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