summaryrefslogtreecommitdiff
path: root/lib/VN3/Trait/JS.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-12-30 09:49:13 +0100
committerYorhel <git@yorhel.nl>2019-12-30 09:49:13 +0100
commitd79c982ee876502db2e1a12752667c6a198c2ddc (patch)
treeccd4a4e72e5b0d3dd412bed6aee58044e93893f0 /lib/VN3/Trait/JS.pm
parente146ed7bda12d369532e485ca0c2e3d823811854 (diff)
Actually, let's get rid of v3 now that it doesn't work anymore anyway
Diffstat (limited to 'lib/VN3/Trait/JS.pm')
-rw-r--r--lib/VN3/Trait/JS.pm44
1 files changed, 0 insertions, 44 deletions
diff --git a/lib/VN3/Trait/JS.pm b/lib/VN3/Trait/JS.pm
deleted file mode 100644
index 05e1d03d..00000000
--- a/lib/VN3/Trait/JS.pm
+++ /dev/null
@@ -1,44 +0,0 @@
-package VN3::Trait::JS;
-
-use VN3::Prelude;
-
-my $elm_TraitResult = elm_api TraitResult => { aoh => {
- id => { id => 1 },
- name => {},
- gid => { id => 1, required => 0 },
- group => { required => 0 }
-}};
-
-# Returns only approved and applicable traits
-json_api '/js/trait.json', {
- search => { maxlength => 500 }
-}, sub {
- my $q = shift->{search};
-
- my $qs = $q =~ s/[%_]//gr;
- my $r = tuwf->dbAlli(
- 'SELECT t.id, t.name, g.id AS gid, g.name AS group',
- 'FROM (',
- # ID search
- $q =~ /^$IID_RE$/ ? ('SELECT 1, id FROM traits WHERE id =', \"$1", 'UNION ALL') : (),
- # exact match
- 'SELECT 2, id FROM traits WHERE lower(name) = lower(', \$q, ")",
- 'UNION ALL',
- # prefix match
- 'SELECT 3, id FROM traits WHERE name ILIKE', \"$qs%",
- 'UNION ALL',
- # substring match + alias search
- 'SELECT 4, id FROM traits WHERE name ILIKE', \"%$qs%", ' OR alias ILIKE', \"%$qs%",
- ') AS tt (ord, id)',
- 'JOIN traits t ON t.id = tt.id',
- 'LEFT JOIN traits g ON g.id = t.group',
- 'WHERE t.state = 2 AND t.applicable',
- 'GROUP BY t.id, t.name, g.id, g.name',
- 'ORDER BY MIN(tt.ord), t.name',
- 'LIMIT 20'
- );
-
- $elm_TraitResult->($r);
-};
-
-1;