File tree Expand file tree Collapse file tree 4 files changed +20
-6
lines changed
Expand file tree Collapse file tree 4 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -239,17 +239,18 @@ function Frecency:query(opts, epoch)
239239 end )
240240 :totable ()
241241 table.sort (objects , self .database .query_sorter (opts .order , opts .direction ))
242- local results = opts .record and objects
242+ local records = opts .record and objects
243243 or vim
244244 .iter (objects )
245245 :map (function (obj )
246246 return obj .path
247247 end )
248248 :totable ()
249- if # results > opts .limit then
250- results = vim .list_slice (results , 1 , opts .limit )
249+ if # records > opts .limit then
250+ records = vim .list_slice (records , 1 , opts .limit )
251251 end
252- return opts .json and vim .json .encode (results ) or results
252+ local dumped = self .database .tbl :dump (records )
253+ return opts .json and vim .json .encode (dumped ) or dumped
253254end
254255
255256--- @private
Original file line number Diff line number Diff line change @@ -105,4 +105,10 @@ function TableV1:remove_record(key)
105105 self .data .records [key ] = nil
106106end
107107
108+ --- @param records table[]
109+ --- @return table
110+ function TableV1 :dump (records )
111+ return { version = self .version , records = records }
112+ end
113+
108114return TableV1
Original file line number Diff line number Diff line change 3333function EntryV2 :obj ()
3434 return {
3535 path = self .path ,
36- half_life = self .half_life ,
37- reference_time = self .reference_time ,
3836 last_accessed = self .last_accessed ,
3937 num_accesses = self .num_accesses ,
4038 score = self .score ,
Original file line number Diff line number Diff line change @@ -134,4 +134,13 @@ function TableV2:reset_reference_time(epoch)
134134 end
135135end
136136
137+ --- @param records table[]
138+ --- @return table
139+ function TableV2 :dump (records )
140+ local dumped = TableV1 .dump (self , records )
141+ dumped .reference_time = self :reference_time ()
142+ dumped .half_life = self :half_life ()
143+ return dumped
144+ end
145+
137146return TableV2
You can’t perform that action at this time.
0 commit comments