-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfix_abnormal.lua
More file actions
27 lines (23 loc) · 777 Bytes
/
Copy pathfix_abnormal.lua
File metadata and controls
27 lines (23 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local result = {};
local sourceTypes = {1, 2, 3, 4, 11}
--local sourceTypes = {2}
for i = 1, #sourceTypes do
local pattern = 'abnormal:*:'..sourceTypes[i]
redis.log(redis.LOG_NOTICE, "pattern: "..pattern)
local keys = redis.call('keys', pattern)
for j = 1, #keys do
local key = keys[j]
local abnormals = redis.call('lrange', key, 0, -1)
for k = 1, #abnormals do
local obj = cjson.decode(abnormals[k]);
if type(obj.author) ~= 'string' then
redis.log(redis.LOG_NOTICE, key, abnormals[k], type(obj.author))
table.insert(result, key..'#'..(k - 1)..'#'..abnormals[k])
obj.author = ''
abnormals[k] = cjson.encode(obj);
redis.call('lset', key, k - 1, abnormals[k])
end
end
end
end
return result;