/[refeed]/trunk/deduper/reblog-dupe.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/deduper/reblog-dupe.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 19 by dpavlin, Wed Jul 19 13:42:25 2006 UTC revision 20 by dpavlin, Sat Jan 20 13:41:52 2007 UTC
# Line 17  $|++; Line 17  $|++;
17  my $connect = "DBI:mysql:database=reblog";  my $connect = "DBI:mysql:database=reblog";
18  my $dbh = DBI->connect($connect,"","") || die $DBI::errstr;  my $dbh = DBI->connect($connect,"","") || die $DBI::errstr;
19    
20    my $user_id = 1;
21    
22  # select all posts which have been read or unread  # select all posts which have been read or unread
23  my $sql = qq{  my $sql = qq{
24          select          select
25                  id, content, feed_id                  id, content, feed_id
26          from items          from items
27          join items_userdata on id=item_id          join items_userdata on id=item_id
28          where label = 'read' and value_numeric = ?          where label = 'read'
29                    and value_numeric = ?
30                    and user_id = $user_id
31          order by id          order by id
32  };  };
33    
# Line 41  sub strip { Line 45  sub strip {
45          return $t if ($t ne ' ');          return $t if ($t ne ' ');
46  }  }
47    
48    my $i = 0;
49    
50  while (my $row = $sth->fetchrow_hashref() ) {  while (my $row = $sth->fetchrow_hashref() ) {
51    
52          my $t = strip( $row->{content} ) || next;          my $t = strip( $row->{content} ) || next;
53    
54          $deduper->add_doc( $row->{id}, $t );          $deduper->add_doc( $row->{id}, $t );
55    
56          print ".";          $i++;
57            print "$i " if ($i % 100 == 0);
58    
59  }  }
60    
61  print STDERR "\n";  print "\n";
62    
63  my @duplicates;  my @duplicates;
64  my $feeds;  my $feeds;
# Line 116  print "found ", $#duplicates + 1, " dupl Line 123  print "found ", $#duplicates + 1, " dupl
123  $sql = qq{  $sql = qq{
124          update items_userdata          update items_userdata
125          set value_numeric = 1          set value_numeric = 1
126          where label = 'read' and item_id in ($ids)          where label = 'read' and item_id in ($ids) and user_id = $user_id
127  };  };
128    
129  $dbh->do( $sql );  $dbh->do( $sql );
# Line 126  $dbh->do( $sql ); Line 133  $dbh->do( $sql );
133  $sql = qq{  $sql = qq{
134          update feeds_userdata          update feeds_userdata
135          set value_numeric = value_numeric - ?          set value_numeric = value_numeric - ?
136          where label = 'usage_unread' and feed_id = ?          where label = 'usage_unread' and feed_id = ? and user_id = $user_id
137  };  };
138    
139  $sth = $dbh->prepare($sql) || die $dbh->errstr();  $sth = $dbh->prepare($sql) || die $dbh->errstr();

Legend:
Removed from v.19  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26