]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge topic branch t/afs-select into master
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 21 Oct 2023 16:56:48 +0000 (18:56 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 21 Oct 2023 16:58:22 +0000 (18:58 +0200)
A single patch which silences the select command. The merge conflicted
in afs.c, but that was trivial to resolve.

* refs/heads/t/afs-select:
  server: Implement select -verbose.

NEWS.md
afs.c
m4/lls/server_cmd.suite.m4
mood.c

diff --git a/NEWS.md b/NEWS.md
index 22816b1911a7613a233481df0ff4ac7e07bb6a81..aa515e5af091eb23f266549a0cd33e974f993972 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -15,6 +15,9 @@ NEWS
 - The --admissible option of the ls command now takes an optional
   argument. When invoked like --admissible=m/foo, only files which are
   admissible with respect to mood foo are listed.
+- The select server command is now quiet by default, The new --verbose
+  option can be used to show information about the newly loaded mood
+  or playlist.
 
 Downloads:
 [tarball](./releases/paraslash-git.tar.xz)
diff --git a/afs.c b/afs.c
index 3083084c25ac793cfd3a5cad1f93c6e78f0fa413..445d5871097b79cdcd14170c2a1f59998354dc98 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -970,29 +970,32 @@ static int com_select_callback(struct afs_callback_arg *aca)
        const struct lls_command *cmd = SERVER_CMD_CMD_PTR(SELECT);
        const char *arg;
        int ret;
+       struct para_buffer *pbout;
 
        ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
        assert(ret >= 0);
        arg = lls_input(0, aca->lpr);
+       pbout = SERVER_CMD_OPT_GIVEN(SELECT, VERBOSE, aca->lpr)?
+               &aca->pbout : NULL;
        score_clear();
        if (current_play_mode == PLAY_MODE_MOOD)
                mood_unload(NULL);
        else
                playlist_unload(NULL);
-       ret = activate_mood_or_playlist(arg, &aca->pbout);
+       ret = activate_mood_or_playlist(arg, pbout);
        if (ret >= 0)
                goto free_lpr;
        /* ignore subsequent errors (but log them) */
        if (current_mop && strcmp(current_mop, arg) != 0) {
                int ret2;
                afs_error(aca, "switching back to %s\n", current_mop);
-               ret2 = activate_mood_or_playlist(current_mop, &aca->pbout);
+               ret2 = activate_mood_or_playlist(current_mop, pbout);
                if (ret2 >= 0)
                        goto free_lpr;
                afs_error(aca, "could not reactivate %s: %s\n", current_mop,
                        para_strerror(-ret2));
        }
-       activate_mood_or_playlist(NULL, &aca->pbout);
+       activate_mood_or_playlist(NULL, pbout);
 free_lpr:
        lls_free_parse_result(aca->lpr, cmd);
        return ret;
index 1cec68164a13d46fdd96bfcb50c2b0ea160a0585..5b5c59ad58ad4ca07edefa3bd01311155ca1e5d5 100644 (file)
@@ -417,6 +417,9 @@ m4_include(`com_ll.m4')
 
                activates the mood named 'foo'.
        [/description]
+       [option verbose]
+               short_opt = v
+               summary = print information about the loaded mood or playlist
 
 [subcommand sender]
        purpose = control paraslash senders
diff --git a/mood.c b/mood.c
index b4d50c88e73533c69e7473c072e3aaef1c196d99..1e15ef0e081480381fcbc4fdad2179848f429c1f 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -541,12 +541,15 @@ static char *get_statistics(struct mood_instance *m, int64_t sse)
                "loaded mood %s (%u files)\n"
                "last_played mean/sigma: %d/%d days\n"
                "num_played mean/sigma: %" PRId64 "/%" PRIu64 "\n"
+               "correction factor ratio: %.2lf\n"
        ,
                m->name? m->name : "(dummy)",
                n,
                mean_days, sigma_days,
                m->stats.num_played_sum / n,
-                       int_sqrt(m->stats.num_played_qd / n)
+               int_sqrt(m->stats.num_played_qd / n),
+               86400.0 * m->stats.last_played_correction /
+                       m->stats.num_played_correction
        );
 }