Refactor group 2 word selection: use (failure+1)/(success+1) ratio, bump version to 2.8.0
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 35s

This commit is contained in:
Play Life Bot
2026-01-02 16:50:40 +03:00
parent 9e50a718d8
commit 27befeb92b
2 changed files with 5 additions and 6 deletions

View File

@@ -1 +1 @@
2.7.4
2.8.0

View File

@@ -1123,7 +1123,7 @@ func (a *App) getTestWordsHandler(w http.ResponseWriter, r *http.Request) {
group1WordIDs[word.ID] = true
}
// Group 2: (failure - success) >= 5, sorted by (failure - success) DESC, then last_success_at ASC (NULL first)
// Group 2: sorted by (failure + 1)/(success + 1) DESC, take top 40%
// Exclude words already in group1
group2Exclude := ""
group2Args := make([]interface{}, 0)
@@ -1142,15 +1142,14 @@ func (a *App) getTestWordsHandler(w http.ResponseWriter, r *http.Request) {
group2Query := `
SELECT ` + baseSelect + `
` + baseFrom + `
AND (COALESCE(p.failure, 0) - COALESCE(p.success, 0)) >= 5
` + group2Exclude + `
ORDER BY
(COALESCE(p.failure, 0) - COALESCE(p.success, 0)) DESC,
(COALESCE(p.failure, 0) + 1.0) / (COALESCE(p.success, 0) + 1.0) DESC,
CASE WHEN p.last_success_at IS NULL THEN 0 ELSE 1 END,
p.last_success_at ASC
LIMIT $` + fmt.Sprintf("%d", len(group2Args)+1)
group2Args = append(group2Args, group2Count*2) // Get more to ensure uniqueness
group2Args = append(group2Args, group2Count)
group2Rows, err := a.DB.Query(group2Query, group2Args...)
if err != nil {
sendErrorWithCORS(w, err.Error(), http.StatusInternalServerError)
@@ -1160,7 +1159,7 @@ func (a *App) getTestWordsHandler(w http.ResponseWriter, r *http.Request) {
group2Words := make([]Word, 0)
group2WordIDs := make(map[int]bool)
for group2Rows.Next() && len(group2Words) < group2Count {
for group2Rows.Next() {
var word Word
var lastSuccess, lastFailure sql.NullString