summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-06-25 11:26:32 +0200
committerYorhel <git@yorhel.nl>2020-06-25 11:26:35 +0200
commit31386583064ec0f2a47eb9331db2f15653c24994 (patch)
tree09c2e7aa18d4c2980461fb3f4c2ca39e2b8b8994
parent2918338f9caf649a73fc9dbb1a158ade98dc0f1e (diff)
VN::Graph: Always display "unofficial" option if VN has unofficial relations
VNs with both official and unofficial relations would otherwise have no option at all to display those unofficial relations.
-rw-r--r--lib/VNWeb/VN/Graph.pm26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/VNWeb/VN/Graph.pm b/lib/VNWeb/VN/Graph.pm
index 45e8ea73..23ac6201 100644
--- a/lib/VNWeb/VN/Graph.pm
+++ b/lib/VNWeb/VN/Graph.pm
@@ -10,8 +10,8 @@ TUWF::get qr{/$RE{vid}/rg}, sub {
my $unoff = tuwf->validate(get => unoff => { anybool => 1 })->data;
my $v = tuwf->dbRowi('SELECT id, title, original, hidden AS entry_hidden, locked AS entry_locked FROM vn WHERE id =', \$id);
- my $hasofficial = tuwf->dbVali('SELECT 1 FROM vn_relations WHERE official AND id =', \$id, 'LIMIT 1');
- $unoff = 1 if !$hasofficial;
+ my $has = tuwf->dbRowi('SELECT bool_or(official) AS official, bool_or(not official) AS unofficial FROM vn_relations WHERE id =', \$id, 'GROUP BY id');
+ $unoff = 1 if !$has->{official};
# Big list of { id0, id1, relation } hashes.
# Each relation is included twice, with id0 and id1 reversed.
@@ -61,7 +61,7 @@ TUWF::get qr{/$RE{vid}/rg}, sub {
txt_ sprintf "Displaying %d out of %d related visual novels.", $visible_nodes, $total_nodes;
debug_ +{ nodes => $nodes, rel => $rel };
br_;
- if($hasofficial) {
+ if($has->{official}) {
if($unoff) {
txt_ 'Show / ';
a_ href => "?num=$num&unoff=0", 'Hide';
@@ -72,16 +72,18 @@ TUWF::get qr{/$RE{vid}/rg}, sub {
txt_ ' unofficial relations. ';
br_;
}
- txt_ 'Adjust graph size: ';
- join_ ', ', sub {
- if($_ == min $num, $total_nodes) {
- txt_ $_ ;
- } else {
- a_ href => "/v$id/rg?num=$_", $_;
- }
- }, grep($_ < $total_nodes, 10, 15, 25, 50, 75, 100, 150, 250, 500, 750, 1000), $total_nodes;
+ if($total_nodes > 10) {
+ txt_ 'Adjust graph size: ';
+ join_ ', ', sub {
+ if($_ == min $num, $total_nodes) {
+ txt_ $_ ;
+ } else {
+ a_ href => "/v$id/rg?num=$_", $_;
+ }
+ }, grep($_ < $total_nodes, 10, 15, 25, 50, 75, 100, 150, 250, 500, 750, 1000), $total_nodes;
+ }
txt_ '.';
- } if $total_nodes > 10;
+ } if $total_nodes > 10 || $has->{unofficial};
p_ class => 'center', sub { lit_ dot2svg $dot };
};
clearfloat_;