1 package Newslash::Model::Topics;
2 use Newslash::Model::Base -base;
10 my $rs = $self->generic_select(table => 'topics',
11 unique_keys => [qw(tid keyword textname)],
12 keys => [qw(series submittable searchable storypickabe)],
19 my $rs = $self->generic_select(table => 'topic_nexus',
20 unique_keys => [qw(tid)],
21 keys => [qw(tid current_qid)]);
25 sub _select_topic_parents {
29 my $rs = $self->generic_select(table => 'topic_parents',
35 sub get_primary_topic_from_tags {
36 my ($self, $tags) = @_;
37 return if !$tags || !@$tags;
39 my $dbh = $self->connect_db;
41 my @placeholders = map { "?" } @$tags;
42 my $placeholder = join(", ", @placeholders);
46 WHERE keyword IN ($placeholder)
47 OR textname IN ($placeholder)
50 my $sth = $dbh->prepare($sql);
51 $sth->execute(@$tags, @$tags);
52 my $rs = $sth->fetchall_arrayref({});
57 $index->{$item->{keyword}} = $item;
58 $index->{$item->{textname}} = $item;
61 # scan topics by given order
63 for my $tag (@$tags) {
64 next if !defined $index->{$tag};
65 next if $index->{$tag}->{submittable} ne 'yes';
66 $topic = $index->{$tag};