Refactor SQL queries to use parameterized values for player names and similarity percentage
This commit is contained in:
@@ -4,14 +4,14 @@ with char1_achievements as (
|
||||
date,
|
||||
completed
|
||||
from achievements
|
||||
where name = 'Extazyk'
|
||||
where name = $1
|
||||
),
|
||||
char2_achievements as (
|
||||
select id,
|
||||
date,
|
||||
completed
|
||||
from achievements
|
||||
where name = 'Smokemantra'
|
||||
where name = $2
|
||||
),
|
||||
all_achievements as (
|
||||
select id
|
||||
|
@@ -5,7 +5,7 @@ with RECURSIVE connected_players as (
|
||||
total_achievements1 as achievements,
|
||||
similarity_percentage
|
||||
from similar_pairs
|
||||
where similarity_percentage >= 70
|
||||
where similarity_percentage >= $1
|
||||
union
|
||||
select name2,
|
||||
name1,
|
||||
@@ -13,7 +13,7 @@ with RECURSIVE connected_players as (
|
||||
total_achievements2,
|
||||
similarity_percentage
|
||||
from similar_pairs
|
||||
where similarity_percentage >= 70
|
||||
where similarity_percentage >= $1
|
||||
union
|
||||
select case
|
||||
when sp.name1 = cp.player_name then sp.name2
|
||||
@@ -31,7 +31,7 @@ with RECURSIVE connected_players as (
|
||||
sp.name1 = cp.player_name
|
||||
or sp.name2 = cp.player_name
|
||||
)
|
||||
and sp.similarity_percentage >= 70
|
||||
and sp.similarity_percentage >= $1
|
||||
where case
|
||||
when sp.name1 = cp.player_name then sp.name2
|
||||
else sp.name2
|
||||
@@ -45,7 +45,7 @@ select group_root,
|
||||
MIN(matching_count) as min_matching,
|
||||
AVG(matching_count) as avg_matching
|
||||
from connected_players
|
||||
where group_root in ('Paskoo')
|
||||
where group_root in ($2)
|
||||
group by group_root
|
||||
having count(*) > 1
|
||||
order by count(*) desc,
|
||||
|
Reference in New Issue
Block a user