mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 18:45:42 -04:00
syntax errors done, now to do queries
This commit is contained in:
parent
5d56dee64c
commit
f06f3a2f69
2 changed files with 21 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
|||
EXPLAIN WITH RECURSIVE factoid_lookup_order_inner (depth, namespace, server, alias_namespace, alias_server, parent_namespace, parent_server, recursive, gen_server, gen_namespace) AS (
|
||||
WITH RECURSIVE factoid_lookup_order_inner (depth, namespace, server, alias_namespace, alias_server, parent_namespace, parent_server, recursive, gen_server, gen_namespace) AS (
|
||||
SELECT 0 AS depth, namespace, server, alias_namespace, alias_server, parent_namespace, parent_server, recursive, generated_server, generated_namespace
|
||||
FROM factoid_config
|
||||
WHERE namespace = '#perlbot' AND server = 'notfreenode.net' -- PLACEHOLDER TARGET
|
||||
WHERE namespace = '#perlbot' AND server = 'freenode.net' -- PLACEHOLDER TARGET
|
||||
UNION ALL
|
||||
SELECT p.depth+1 AS depth, m.namespace, m.server, m.alias_namespace, m.alias_server, m.parent_namespace, m.parent_server, m.recursive, m.generated_server, m.generated_namespace
|
||||
FROM factoid_config m
|
||||
|
@ -22,7 +22,7 @@ get_latest_factoid (depth, factoid_id, subject, copula, predicate, author, modif
|
|||
WHERE original_subject = 'hi' -- PLACEHOLDER TARGET
|
||||
ORDER BY depth ASC, factoid_id DESC
|
||||
)
|
||||
SELECT * FROM get_latest_factoid WHERE NOT deleted ORDER BY depth ASC, factoid_id DESC;
|
||||
SELECT * FROM get_latest_factoid WHERE NOT deleted ORDER BY depth ASC, factoid_id DESC LIMIT 1;
|
||||
--SELECT * FROM factoid_lookup_order;
|
||||
|
||||
|
||||
|
|
|
@ -104,7 +104,20 @@ sub get_conf_for_channel ($self, $said) {
|
|||
|
||||
my $result = $dbh->selectrow_hashref(qq{
|
||||
SELECT * FROM factoid_config WHERE server = ? AND namespace = ? LIMIT 1
|
||||
}, {}, $server, $name);
|
||||
}, {}, $server, $namespace);
|
||||
|
||||
my $conf = {
|
||||
server => '',
|
||||
namespace => '',
|
||||
alias_server => '',
|
||||
alias_namespace => '',
|
||||
parent_server => undef,
|
||||
parent_namespace => undef,
|
||||
recursive => 0,
|
||||
command_prefix => undef,
|
||||
|
||||
%{$result//{}},
|
||||
};
|
||||
|
||||
return $conf;
|
||||
}
|
||||
|
@ -151,7 +164,7 @@ sub command ($self, $_said, $pm) {
|
|||
$said->{channel} = "##NULL" if $said->{channel} eq '*irc_msg';
|
||||
}
|
||||
|
||||
if ($body =~ /^\s*(?<channel>#\S+)\s+(?<fact>.*)$/) {
|
||||
if ($said->{body} =~ /^\s*(?<channel>#\S+)\s+(?<fact>.*)$/) {
|
||||
$said->{channel} = $+{channel};
|
||||
$said->{body} = $+{fact};
|
||||
}
|
||||
|
@ -308,7 +321,6 @@ sub store_factoid ($self, $said) {
|
|||
}
|
||||
|
||||
sub _insert_factoid ($self, $author, $subject, $copula, $predicate, $compose_macro, $protected, $server, $namespace) {
|
||||
my = @_;
|
||||
my $dbh = $self->dbh;
|
||||
|
||||
warn "Attempting to insert factoid: type $compose_macro";
|
||||
|
@ -410,7 +422,7 @@ sub _fact_literal_format($r) {
|
|||
($r->{protected} ? "P:" : "") . ("", "macro ", "func ")[$r->{compose_macro}] . "$r->{subject} $r->{copula} $r->{predicate}";
|
||||
}
|
||||
|
||||
sub get_fact_revisions ($self, $subject, $name) {
|
||||
sub get_fact_revisions ($self, $subject, $name, $said) {
|
||||
my $dbh = $self->dbh;
|
||||
|
||||
my ($server, $namespace) = $self->get_namespace($said);
|
||||
|
@ -431,8 +443,7 @@ sub get_fact_revisions ($self, $subject, $name) {
|
|||
return $ret_string;
|
||||
}
|
||||
|
||||
sub get_fact_literal ($self, $subject, $name) {
|
||||
|
||||
sub get_fact_literal ($self, $subject, $name, $said) {
|
||||
my ($server, $namespace) = $self->get_namespace($said);
|
||||
my $fact = $self->_db_get_fact(_clean_subject($subject), $name, $server, $namespace);
|
||||
|
||||
|
@ -571,7 +582,7 @@ sub get_fact_learn ($self, $body, $name, $said, $subject, $predicate) {
|
|||
return "Stored $subject as $predicate";
|
||||
}
|
||||
|
||||
sub get_fact_search ($self, $body, $name) {
|
||||
sub get_fact_search ($self, $body, $name, $said) {
|
||||
|
||||
# TODO replace this with FTS
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue