Only suggest text not older than three years
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / infocon
index 8fe4c52..343303f 100755 (executable)
@@ -22,6 +22,7 @@ use warnings;
 
 use DBI;
 use Scalar::Util qw/reftype/;
+use Date::Calc qw/Add_Delta_YM/;
 use Term::ReadLine;
 use Getopt::Long;
 
@@ -315,9 +316,13 @@ sub complete_category
 
     return () unless exists $answers->{category} && length $answers->{category};
 
-    my $sql = sprintf("SELECT DISTINCT description FROM %s WHERE category = '%s' AND description LIKE '%s%%' ORDER BY description",
+    my @now = localtime();
+    my ($year,$month,$day) = Add_Delta_YM($now[5]+1900, $now[4]+1, $now[3], -3, 0);
+
+    my $sql = sprintf("SELECT DISTINCT description FROM %s WHERE category = '%s' AND date > '%04d%02d%02d' AND description LIKE '%s%%' ORDER BY description",
                      $table,
                      $answers->{category},
+                     $year,$month,$day,
                      $line);
     my $sth = $dbh->prepare($sql);
     $sth->execute;