admin: Able to reset issues, QA and events
This commit is contained in:
parent
9a2fd85d57
commit
ba096c0af1
3 changed files with 23 additions and 4 deletions
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
// truncateTable performs an insecure wipe on the given tables.
|
||||
func truncateTable(tables ...string) (error) {
|
||||
func truncateTable(tables ...string) error {
|
||||
if tx, err := db.BeginTx(context.TODO(), nil); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
|
@ -27,8 +27,20 @@ func truncateTable(tables ...string) (error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ResetAnnexes resets all tables containing annexe info like events, claims and qa.
|
||||
func ResetAnnexes() error {
|
||||
return truncateTable(
|
||||
"claim_descriptions",
|
||||
"claims",
|
||||
"events",
|
||||
"qa_comments",
|
||||
"teams_qa_todo",
|
||||
"teams_qa_view",
|
||||
)
|
||||
}
|
||||
|
||||
// ResetGame resets all tables containing team attempts and solves.
|
||||
func ResetGame() (error) {
|
||||
func ResetGame() error {
|
||||
return truncateTable(
|
||||
"team_wchoices",
|
||||
"team_hints",
|
||||
|
|
@ -40,7 +52,7 @@ func ResetGame() (error) {
|
|||
}
|
||||
|
||||
// ResetExercices wipes out all challenges (both attempts and statements).
|
||||
func ResetExercices() (error) {
|
||||
func ResetExercices() error {
|
||||
return truncateTable(
|
||||
"team_wchoices",
|
||||
"team_hints",
|
||||
|
|
@ -55,6 +67,10 @@ func ResetExercices() (error) {
|
|||
"exercice_hints_okey_deps",
|
||||
"exercice_hints_omcq_deps",
|
||||
"flag_choices",
|
||||
"exercice_flag_deps",
|
||||
"exercice_flag_labels_omcq_deps",
|
||||
"exercice_flag_labels_deps",
|
||||
"exercice_flag_labels",
|
||||
"exercice_flags",
|
||||
"exercice_solved",
|
||||
"exercice_tries",
|
||||
|
|
@ -69,7 +85,7 @@ func ResetExercices() (error) {
|
|||
}
|
||||
|
||||
// ResetTeams wipes out all teams, incluings members and attempts.
|
||||
func ResetTeams() (error) {
|
||||
func ResetTeams() error {
|
||||
return truncateTable(
|
||||
"team_wchoices",
|
||||
"team_hints",
|
||||
|
|
|
|||
Reference in a new issue