Skip to content

Commit b52aeff

Browse files
authored
Handle alert ref in the FP stats query (#236)
Remove the ref part and use just the alert ID, as before, when counting the FPs. Signed-off-by: thc202 <thc202@gmail.com>
1 parent 3f96af9 commit b52aeff

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

stats/website_stats2.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ def gen_top_fps_file():
189189
print('---', file=f)
190190

191191
aws_athena_query_to_file(
192-
'SELECT stat, "substr"(stat, 19, ("length"(stat) - 26)) pluginId, alerts.name, alerts.status, alerts.type, "sum"(value) count ' +
192+
'SELECT alerts.pluginId, alerts.name, alerts.status, alerts.type, "sum"(value) count ' +
193193
'FROM ("project_zap_stats"."tel_therest" ' +
194-
'INNER JOIN "project_zap_stats"."alerts" ON (alerts.pluginId = CAST("substr"(tel_therest.stat, 19, ("length"(stat) - 26)) AS integer))) ' +
194+
'INNER JOIN "project_zap_stats"."alerts" ON (alerts.pluginId = CAST("split_part"("substr"(tel_therest.stat, 19, ("length"(stat) - 26)), \'-\', 1) AS integer))) ' +
195195
'WHERE (' + last_mon_sql + ' AND (stat LIKE \'stats.alertFilter%-1\')) ' +
196-
'GROUP BY stat, alerts.name, alerts.status, alerts.type ' +
196+
'GROUP BY alerts.pluginId, alerts.name, alerts.status, alerts.type ' +
197197
'ORDER BY count DESC LIMIT 20', tempfile)
198198
if os.path.isfile(tempfile):
199199
first = True
@@ -204,10 +204,10 @@ def gen_top_fps_file():
204204
first = False
205205
else:
206206
vals = line.split(',')
207-
print('- id: ' + vals[1].replace('"', ''), file=f)
208-
print(' name: ' + vals[2], file=f)
209-
print(' status: ' + vals[3], file=f)
210-
print(' type: ' + vals[4], file=f)
207+
print('- id: ' + vals[0].replace('"', ''), file=f)
208+
print(' name: ' + vals[1], file=f)
209+
print(' status: ' + vals[2], file=f)
210+
print(' type: ' + vals[3], file=f)
211211

212212
def gen_top_ascan_rules_file():
213213
outfile = utils.websitedir() + 'site/data/charts/top_ascan_rules_last_month.yaml'

0 commit comments

Comments
 (0)