diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2023-03-27 00:18:01 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2023-03-27 00:18:01 -0700 |
commit | 7d120b7939aa5bae68dbb5fc2f877cc8220c6929 (patch) | |
tree | 626466ffe3de7e864e3fe3165f4a4890240febce | |
parent | 0f9c5617c41b0701c5c9935db069249d824a8c7c (diff) | |
download | backomp-7d120b7939aa5bae68dbb5fc2f877cc8220c6929.tar.gz backomp-7d120b7939aa5bae68dbb5fc2f877cc8220c6929.tar.xz |
make prioritisation behaviour more configurable
-rwxr-xr-x | backomp | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -6,13 +6,16 @@ set -e function flr(n, s) { return int(n / s) * s } BEGIN { - split("h d w m", buckets) - for (i in buckets) { - if (match(retain, "([*0-9]+)" buckets[i], md) && md[1]) - ret[buckets[i]] = md[1] + split("h d w m", arr) + for (i = 1; i <= length(arr); ++i) { + b = arr[i] - if (index(replace, buckets[i])) - repl[buckets[i]] = 1 + if (!match(retain, "([*0-9]+)" b, md)) + continue + ret[b] = md[1] + buckets[++n_buckets] = b + + repl[b] = !!index(replace, b) } } @@ -25,14 +28,22 @@ BEGIN { bt["m"] = mktime(strftime("%Y %m", t, 1) " 01 00 00 00", 1) bt["w"] = bt["m"] + flr(t - bt["m"], 7*24*60*60) - for (i = 1; i <= length(buckets); ++i) { + for (i = 1; i <= n_buckets; ++i) { b = buckets[i] - if (!ret[b] || (b in repl && (b, bt[b]) in bkeep)) - continue + if (skip = (repl[b] && bt[b] == last[b, b])) { + for (j = 1; j < i; ++j) { + skip = (bt[buckets[j]] != last[b, buckets[j]]) + if (!skip) break + } + if (skip) next + } if ((b, bt[b]) in bkeep || ret[b] == "*" || bc[b]++ < ret[b]) bkeep[b, bt[b]] = $1 + + for (j in buckets) + last[b, buckets[j]] = bt[buckets[j]] } } |