New setting: introduce a decote/discount to exercice's gain
This commit is contained in:
parent
838ce2fb3f
commit
4451e41285
11 changed files with 123 additions and 24 deletions
13
libfic/db.go
13
libfic/db.go
|
|
@ -3,6 +3,7 @@ package fic
|
|||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
|
@ -548,10 +549,22 @@ CREATE TABLE IF NOT EXISTS teams_qa_view(
|
|||
if _, err := db.Exec("CREATE OR REPLACE VIEW exercice_distinct_tries_notgood AS SELECT id_exercice, id_team, MAX(time) AS time, cksum, nbdiff, MAX(onegood) AS onegood FROM exercice_tries_notgood GROUP BY id_team, id_exercice, cksum;"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := DBRecreateDiscountedView(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DBRecreateDiscountedView() (err error) {
|
||||
if db == nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = db.Exec("CREATE OR REPLACE VIEW exercices_discounted AS SELECT E.id_exercice, E.id_theme, E.title, E.disabled, E.headline, E.url_id, E.path, E.statement, E.overview, E.issue, E.issue_kind, E.depend, E.gain - " + fmt.Sprintf("%f", DiscountedFactor) + " * E.gain * (COUNT(*) - 1) AS gain, E.coefficient_cur, E.finished, E.video_uri, E.resolution, E.seealso FROM exercices E LEFT OUTER JOIN exercice_solved S ON S.id_exercice = E.id_exercice GROUP BY E.id_exercice;")
|
||||
return
|
||||
}
|
||||
|
||||
// DBClose closes the connection to the database
|
||||
func DBClose() error {
|
||||
return db.Close()
|
||||
|
|
|
|||
Reference in a new issue