aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-07-17 12:11:06 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-07-17 12:22:32 +0100
commit890c5658b9551733f9f12ed8504346ead63a1af3 (patch)
tree6e806924ed8bfb089e5a1a852d426dc4a359d44b /src/plugins
parent34d53fc46e55da9ac5535efef9b7186ca23c5586 (diff)
downloadrspamd-890c5658b9551733f9f12ed8504346ead63a1af3.tar.gz
rspamd-890c5658b9551733f9f12ed8504346ead63a1af3.zip
[Minor] Optimize task:get_urls calls
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/clickhouse.lua35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index fb4db3fc9..200fcaeca 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -633,9 +633,9 @@ local function clickhouse_collect(task)
end
local nurls = 0
- if task:has_urls(true) then
- nurls = #task:get_urls(true)
- end
+ local task_urls = task:get_urls(true) or {}
+
+ nurls = #task_urls
local timestamp = math.floor(task:get_date({
format = 'connect',
@@ -757,27 +757,22 @@ local function clickhouse_collect(task)
-- Urls step
local urls_urls = {}
- if task:has_urls(false) then
- for _,u in ipairs(task:get_urls(false)) do
- if settings['full_urls'] then
- urls_urls[u:get_text()] = u
- else
- urls_urls[u:get_host()] = u
- end
+ for _,u in ipairs(task_urls) do
+ if settings['full_urls'] then
+ urls_urls[u:get_text()] = u
+ else
+ urls_urls[u:get_host()] = u
end
-
- -- Get tlds
- table.insert(row, flatten_urls(function(_, u)
- return u:get_tld() or u:get_host()
- end, urls_urls))
- -- Get hosts/full urls
- table.insert(row, flatten_urls(function(k, _) return k end, urls_urls))
- else
- table.insert(row, {})
- table.insert(row, {})
end
+ -- Get tlds
+ table.insert(row, flatten_urls(function(_, u)
+ return u:get_tld() or u:get_host()
+ end, urls_urls))
+ -- Get hosts/full urls
+ table.insert(row, flatten_urls(function(k, _) return k end, urls_urls))
+
-- Emails step
if task:has_urls(true) then
table.insert(row, flatten_urls(function(k, _) return k end,