summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-11-02 10:43:47 +0100
committerYorhel <git@yorhel.nl>2019-11-02 10:43:47 +0100
commit2cd005791529c6501901ac2bc0a7752f88fa7481 (patch)
treeaec3c0a19e08f9cf821c8b3a65bb95d5df12e723 /lib/VNDB
parent155f4d335a698f6cef6f0ddaf932d3302ebcc53d (diff)
Add character cup size field + conversion + filter
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/DB/Chars.pm8
-rw-r--r--lib/VNDB/Handler/Chars.pm13
-rw-r--r--lib/VNDB/Types.pm9
-rw-r--r--lib/VNDB/Util/Misc.pm2
4 files changed, 24 insertions, 8 deletions
diff --git a/lib/VNDB/DB/Chars.pm b/lib/VNDB/DB/Chars.pm
index e2581f87..d5078a1d 100644
--- a/lib/VNDB/DB/Chars.pm
+++ b/lib/VNDB/DB/Chars.pm
@@ -24,6 +24,8 @@ sub dbCharFilters {
defined $o{height_max} ? ( 'c.height <= ? AND c.height > 0' => $o{height_max} ) : (),
defined $o{weight_min} ? ( 'c.weight >= ?' => $o{weight_min} ) : (),
defined $o{weight_max} ? ( 'c.weight <= ?' => $o{weight_max} ) : (),
+ defined $o{cup_min} ? ( 'c.cup_size >= ?' => $o{cup_min} ) : (),
+ defined $o{cup_max} ? ( 'c.cup_size <= ?' => $o{cup_max} ) : (),
$o{role} ? (
'EXISTS(SELECT 1 FROM chars_vns cvi WHERE cvi.id = c.id AND cvi.role IN(!l))',
[ ref $o{role} ? $o{role} : [$o{role}] ] ) : (),
@@ -69,7 +71,7 @@ sub dbCharGet {
);
my @select = (qw|c.id c.name c.original c.gender|);
- push @select, qw|c.hidden c.locked c.alias c.desc c.image c.b_month c.b_day c.s_bust c.s_waist c.s_hip c.height c.weight c.bloodt c.main c.main_spoil| if $o{what} =~ /extended/;
+ push @select, qw|c.hidden c.locked c.alias c.desc c.image c.b_month c.b_day c.s_bust c.s_waist c.s_hip c.height c.weight c.bloodt c.cup_size c.main c.main_spoil| if $o{what} =~ /extended/;
my($r, $np) = $self->dbPage(\%o, q|
SELECT !s
@@ -92,7 +94,7 @@ sub dbCharGetRev {
my $select = 'c.itemid AS id, ch.name, ch.original, ch.gender';
$select .= ', extract(\'epoch\' from c.added) as added, c.comments, c.rev, c.ihid, c.ilock, '.VNWeb::DB::sql_user();
$select .= ', c.id AS cid, NOT EXISTS(SELECT 1 FROM changes c2 WHERE c2.type = c.type AND c2.itemid = c.itemid AND c2.rev = c.rev+1) AS lastrev';
- $select .= ', ch.alias, ch.desc, ch.image, ch.b_month, ch.b_day, ch.s_bust, ch.s_waist, ch.s_hip, ch.height, ch.weight, ch.bloodt, ch.main, ch.main_spoil, co.hidden, co.locked' if $o{what} =~ /extended/;
+ $select .= ', ch.alias, ch.desc, ch.image, ch.b_month, ch.b_day, ch.s_bust, ch.s_waist, ch.s_hip, ch.height, ch.weight, ch.bloodt, ch.cup_size, ch.main, ch.main_spoil, co.hidden, co.locked' if $o{what} =~ /extended/;
my $r = $self->dbAll(q|
SELECT !s
@@ -175,7 +177,7 @@ sub dbCharRevisionInsert {
my($self, $o) = @_;
my %set = map exists($o->{$_}) ? (qq|"$_" = ?|, $o->{$_}) : (),
- qw|name original alias desc image b_month b_day s_bust s_waist s_hip height weight bloodt gender main main_spoil|;
+ qw|name original alias desc image b_month b_day s_bust s_waist s_hip height weight bloodt cup_size gender main main_spoil|;
$self->dbExec('UPDATE edit_chars !H', \%set) if keys %set;
if($o->{traits}) {
diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm
index 59b365fe..1fb0feb6 100644
--- a/lib/VNDB/Handler/Chars.pm
+++ b/lib/VNDB/Handler/Chars.pm
@@ -56,6 +56,7 @@ sub page {
[ height => 'Height', serialize => sub { $_[0]||'[empty]' } ],
[ weight => 'Weight', serialize => sub { $_[0]//'[empty]' } ],
[ bloodt => 'Blood type', serialize => sub { $BLOOD_TYPE{$_[0]} } ],
+ [ cup_size => 'Cup size', serialize => sub { $CUP_SIZE{$_[0]} } ],
[ main => 'Main character',htmlize => sub { $_[0] ? sprintf '<a href="/c%d">c%d</a>', $_[0], $_[0] : '[empty]' } ],
[ main_spoil=> 'Spoiler', serialize => \&fmtspoil ],
[ image => 'Image', htmlize => sub {
@@ -171,14 +172,15 @@ sub charTable {
td $r->{alias};
end;
}
- if(defined($r->{weight}) || $r->{height} || $r->{s_bust} || $r->{s_waist} || $r->{s_hip}) {
+ if(defined($r->{weight}) || $r->{height} || $r->{s_bust} || $r->{s_waist} || $r->{s_hip} || $r->{cup_size}) {
Tr;
td class => 'key', 'Measurements';
td join ', ',
- $r->{height} ? "Height: $r->{height}cm" : (),
+ $r->{height} ? "Height: $r->{height}cm" : (),
defined($r->{weight}) ? "Weight: $r->{weight}kg" : (),
$r->{s_bust} || $r->{s_waist} || $r->{s_hip} ?
- sprintf 'Bust-Waist-Hips: %s-%s-%scm', $r->{s_bust}||'??', $r->{s_waist}||'??', $r->{s_hip}||'??' : ();
+ sprintf 'Bust-Waist-Hips: %s-%s-%scm', $r->{s_bust}||'??', $r->{s_waist}||'??', $r->{s_hip}||'??' : (),
+ $r->{cup_size} ? "$CUP_SIZE{$r->{cup_size}} cup" : ();
end;
}
if($r->{b_month} && $r->{b_day}) {
@@ -303,7 +305,7 @@ sub edit {
|| $id && (($r->{locked} || $r->{hidden}) && !$self->authCan('dbmod'));
my %b4 = !$id ? () : (
- (map +($_ => $r->{$_}), qw|name original alias desc image ihid ilock s_bust s_waist s_hip height weight bloodt gender main_spoil|),
+ (map +($_ => $r->{$_}), qw|name original alias desc image ihid ilock s_bust s_waist s_hip height weight bloodt cup_size gender main_spoil|),
main => $r->{main}||0,
bday => $r->{b_month} ? sprintf('%02d-%02d', $r->{b_month}, $r->{b_day}) : '',
traits => join(' ', map sprintf('%d-%d', $_->{tid}, $_->{spoil}), sort { $a->{tid} <=> $b->{tid} } @{$r->{traits}}),
@@ -328,6 +330,7 @@ sub edit {
{ post => 'height', required => 0, default => 0, template => 'uint', max => 32767 },
{ post => 'weight', required => 0, default => undef, template => 'uint', max => 32767 },
{ post => 'bloodt', required => 0, default => 'unknown', enum => [ keys %BLOOD_TYPE ] },
+ { post => 'cup_size', required => 0, default => '', enum => [ keys %CUP_SIZE ] },
{ post => 'main', required => 0, default => 0, template => 'id' },
{ post => 'main_spoil', required => 0, default => 0, enum => [ 0..2 ] },
{ post => 'traits', required => 0, default => '', regex => [ qr/^(?:[1-9]\d*-[0-2])(?: +[1-9]\d*-[0-2])*$/, 'Incorrect trait format.' ] },
@@ -414,6 +417,8 @@ sub edit {
[ input => name => 'Weight', short => 'weight', width => 50, post => ' kg', allow0 => 1 ],
[ select => name => 'Blood type',short => 'bloodt', options => [
map [ $_, $BLOOD_TYPE{$_} ], keys %BLOOD_TYPE ] ],
+ [ select => name => 'Cup size', short => 'cup_size', options => [
+ map [ $_, $CUP_SIZE{$_} ], keys %CUP_SIZE ] ],
[ static => content => '<br />' ],
[ input => name => 'Instance of',short => 'main', width => 50, post => ' ID of the main character - the character of which this is an instance of.' ],
[ select => name => 'Spoiler', short => 'main_spoil', options => [
diff --git a/lib/VNDB/Types.pm b/lib/VNDB/Types.pm
index 3d613a08..8e5b26cf 100644
--- a/lib/VNDB/Types.pm
+++ b/lib/VNDB/Types.pm
@@ -324,6 +324,15 @@ hash GENDER =>
+# SQL: ENUM cup_size
+hash CUP_SIZE =>
+ '' => 'Unknown or N/A',
+ AAA => 'AAA',
+ AA => 'AA',
+ map +($_,$_), 'A'..'Z';
+
+
+
# SQL: ENUM char_role
hash CHAR_ROLE =>
main => { txt => 'Protagonist', plural => 'Protagonists' },
diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm
index b7a2a3a7..9227d22a 100644
--- a/lib/VNDB/Util/Misc.pm
+++ b/lib/VNDB/Util/Misc.pm
@@ -15,7 +15,7 @@ our @EXPORT = qw|filFetchDB filCompat bbSubstLinks entryLinks|;
our %filfields = (
vn => [qw|date_before date_after released length hasani hasshot tag_inc tag_exc taginc tagexc tagspoil lang olang plat staff_inc staff_exc ul_notblack ul_onwish ul_voted ul_onlist|],
release => [qw|type patch freeware doujin uncensored date_before date_after released minage lang olang resolution plat prod_inc prod_exc med voiced ani_story ani_ero engine|],
- char => [qw|gender bloodt bust_min bust_max waist_min waist_max hip_min hip_max height_min height_max va_inc va_exc weight_min weight_max trait_inc trait_exc tagspoil role|],
+ char => [qw|gender bloodt bust_min bust_max waist_min waist_max hip_min hip_max height_min height_max va_inc va_exc weight_min weight_max cup_min cup_max trait_inc trait_exc tagspoil role|],
staff => [qw|gender role truename lang|],
);