Remove dead functions from src/prompt.lua
John Smith

John Smith commited on 2023-177 12:38:37
Showing 1 changed files, with 0 additions and 61 deletions.

... ...
@@ -58,65 +58,4 @@ function Prompt:retention()
58 58
     return self.succ / (self.succ + self.fail)
59 59
 end
60 60
 
61
---[[
62
-    extracts `Prompt`s from a record-based deck
63
-    returns a table of tables of `Prompt`s
64
-]]
65
-function Prompt:fromrecs(recs, conf)
66
-    local ret = {}
67
-    for i, rec in ipairs(recs) do
68
-        -- only bother with records with `PromptText`
69
-        if rec.PromptText then
70
-            ret[i] = {}
71
-            local opt = rec.PromptText[1]
72
-            local m, n = opt:find "%{[^%}]+%}"
73
-            local ctr = 1
74
-            while m do
75
-                local mpt = opt:sub(1, m - 1) .. "%A" .. opt:sub(n + 1)
76
-                table.insert(ret[i], Prompt:new(
77
-                    mpt,
78
-                    opt:sub(m + 1, n - 1),
79
-                    (rec.LastReview or {})[ctr] or (rec.LastReview or {})[1],
80
-                    (rec.LastDelay or {})[ctr] or 15,
81
-                    (rec.Successes or {})[ctr] or 0,
82
-                    (rec.Failures or {})[ctr] or 0,
83
-                    (rec.Created or {})[1],
84
-                    (rec.Ease or {})[ctr] or conf:get("StartingEase") or "2.5"
85
-                ))
86
-                m, n = opt:find("%{[^%}]+%}", n)
87
-                ctr = ctr + 1
88
-            end
89
-        end
90
-    end
91
-    return ret
92
-end
93
-
94
---[[
95
-    serialises an ordered table of `Prompt`s derived from the same `PromptText` to a record
96
-    returns (on success) a table mapping labels to value-lists
97
-    returns (on failure) nil
98
-]]
99
-function Prompt:torec(prompts)
100
-    if prompts[1].deleted then
101
-        return {}
102
-    end
103
-    local fspt = prompts[1]:spt()
104
-    local ret = { PromptText = { fspt }, LastReview = {}, LastDelay = {}, Successes = {}, Failures = {}, Ease = {} }
105
-    if prompts[1].created then
106
-        ret.Created = { prompts[1].created }
107
-    end
108
-    for i, pr in ipairs(prompts) do
109
-        if pr:spt() ~= fspt then
110
-            -- not from the same `PromptText`
111
-            return nil
112
-        end
113
-        ret.LastReview[i] = pr.time
114
-        ret.LastDelay[i] = pr.delay
115
-        ret.Successes[i] = pr.succ
116
-        ret.Failures[i] = pr.fail
117
-        ret.Ease[i] = pr.ease
118
-    end
119
-    return ret
120
-end
121
-
122 61
 return Prompt
123 62