--- trunk/sql/pgbits.pl 2005/08/02 00:42:29 36 +++ trunk/sql/pgbits.pl 2005/08/02 15:20:44 37 @@ -11,9 +11,10 @@ user => 'dpavlin', passwd => '', catalog => { - path => '/rest/references/PgGeneratBits/bits', - title => 'PostgreSQL General Bits', + name => 'PostgreSQL General Bits', + path => '/rest/references/PgGeneratBits/bits', uri => 'http://www.varlena.com/varlena/GeneralBits/archive.php', + type => 'pgbits', }, }; @@ -28,8 +29,8 @@ relationships => 1, ); -my $this_catalog = $l->find_class('catalog_webarchive')->find_or_create( $self->{catalog} ); -$this_catalog->dbi_commit; +my $top = $l->find_class('topics_webarchive')->find_or_create( $self->{catalog} ); +$top->dbi_commit; sub issue { my $file = shift || die; @@ -43,19 +44,16 @@ $issue_date = $1; print "## issue $issue_no on $issue_date [$file]\n"; - $this_entry = $l->find_class('entries_pgbits')->find_or_create( + $issue = $l->find_class('topics_pgbits')->find_or_create( + name => "issue $issue_no", date => $issue_date, - issue => $issue_no, path => $file, - title => $self->{catalog}->{title} . " :: $issue_no", + issue => $issue_no, + type => 'pgbits', + parent_id => $top->id, ); - $this_entry->dbi_commit; + $issue->dbi_commit; - $l->find_class('catalog_entry')->find_or_create( - catalog_id => $this_catalog->id, - entry_id => $this_entry->id, - e_type => 'pgbits', - )->dbi_commit; } else { warn "can't find issue number and date in $file, skipping\n"; return; @@ -64,7 +62,7 @@ while($html =~ s#^.*?.+?\s*([^<]+)\s*.+?\s*([^<]+)\s*.+?\s*([^<]+)\s*.+?\s*(.+?)\s*\s*(.+?)\s*##si){ my $row = { - title => $2 . ( $3 ? " :: $3" : ""), + name => $2 . ( $3 ? " :: $3" : ""), ikey => $1, mytitle => $2, @@ -73,12 +71,17 @@ html => $5, contributors => $6, - entry_id => $this_entry->id, - i_type => 'pgbits', + type => 'pgbits', }; - - print $row->{title}," ", $row->{date},"\n"; - $l->find_class('items_pgbits')->find_or_create( $row )->dbi_commit; + + print $row->{name}," ", $row->{date},"\n"; + my $article = $l->find_class('items_pgbits')->find_or_create( $row ); + $article->dbi_commit; + + $l->find_class('item_topics')->find_or_create( + topic_id => $issue->id, + item_id => $article->id, + )->dbi_commit; } }