Refactor SQL queries to use parameterized values for player names and similarity percentage

This commit is contained in:
2025-05-24 22:14:30 +02:00
parent 54cd559abe
commit cdefc1735f
2 changed files with 7 additions and 7 deletions

View File

@@ -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

View File

@@ -5,15 +5,15 @@ 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,
matching_count,
total_achievements2,
similarity_percentage
from similar_pairs
where similarity_percentage >= 70
from similar_pairs
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,