djjudas21 / photodb-perl

App to manage a collection of film cameras & lenses
https://metacpan.org/pod/App::PhotoDB
GNU General Public License v2.0
1 stars 2 forks source link

Rewrite legacy query args #198

Closed djjudas21 closed 5 years ago

djjudas21 commented 5 years ago

Rewrite anything that is still using a hardcoded query parameter and instead replace it with SQL::Abstract. Then tidy up the functions and docs.

lib/funcs.pm:   return &lookupval({db=>$db, query=>'select curdate()'});
lib/funcs.pm:   return &lookupval({db=>$db, query=>'select now()'});
lib/funcs.pm:       my $neg_id = &lookupval({db=>$db, query=>"select lookupneg($film_id, $frame)"});
lib/funcs.pm:   my $neg_id = &lookupval({db=>$db, query=>"select lookupneg('$film_id', '$frame')"});
lib/funcs.pm:       my $filmdir = &lookupval({db=>$db, query=>"select directory from FILM where film_id=$film_id"});
lib/handlers.pm:    my $min_shutter_speed = &listchoices({db=>$db, keyword=>'min (fastest) shutter speed', query=>"SELECT shutter_speed as id, '' as opt FROM photography.SHUTTER_SPEED where shutter_speed not in ('B', 'T') and shutter_speed not in (select shutter_speed from SHUTTER_SPEED_AVAILABLE where camera_id=$cameraid) order by duration", type=>'text', insert_handler=>\&shutterspeed_add, required=>1});
lib/handlers.pm:    my $max_shutter_speed = &listchoices({db=>$db, keyword=>'max (slowest) shutter speed', query=>"SELECT shutter_speed as id, '' as opt FROM photography.SHUTTER_SPEED where shutter_speed not in ('B', 'T') and duration > $min_shutter_speed_duration and shutter_speed not in (select shutter_speed from SHUTTER_SPEED_AVAILABLE where camera_id=$cameraid) order by duration", type=>'text', insert_handler=>\&shutterspeed_add, required=>1});
lib/handlers.pm:        $shutterdata{shutter_speed} = &listchoices({db=>$db, keyword=>'shutter speed', query=>"SELECT shutter_speed as id, '' as opt FROM photography.SHUTTER_SPEED where shutter_speed not in ('B', 'T') and duration > $min_shutter_speed_duration and duration < $max_shutter_speed_duration and shutter_speed not in (select shutter_speed from SHUTTER_SPEED_AVAILABLE where camera_id=$cameraid) order by duration", type=>'text', insert_handler=>\&shutterspeed_add, required=>1});
lib/handlers.pm:        $filter_dia = &lookupval({db=>$db, query=>"select if(filter_thread, filter_thread, 0) from LENS where lens_id=$data{lens_id}"});
lib/handlers.pm:    my $modeaperture = &lookupval({db=>$db, query=>"select aperture from (select aperture, count(aperture) from NEGATIVE where lens_id=$lens_id and aperture is not null group by aperture order by count(aperture) desc limit 1) as t1"});
lib/handlers.pm:    return &lookupval({db=>$db, query=>"select print_unarchive($print_id)"});
lib/handlers.pm:    &printlist({db=>$db, msg=>"items in archive $archive_name", query=>$query});
lib/handlers.pm:                        my $neg_id = &lookupval({db=>$db, query=>"select lookupneg($film_id, '$frame')"});
djjudas21 commented 5 years ago

Functions mentioned above are &lookupval, &listchoices and &printlist