summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xadd_some_data.pl71
-rw-r--r--sphinxtest.pl10
2 files changed, 81 insertions, 0 deletions
diff --git a/add_some_data.pl b/add_some_data.pl
new file mode 100755
index 0000000..3362d11
--- /dev/null
+++ b/add_some_data.pl
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+use Data::Dumper;
+use DateTime;
+use lib 'lib';
+use JournalApp::Schema;
+
+my $entry1 = {
+ id => 1,
+ fulltext => "hello world test test test",
+ image_url => "http://myimage.com/new.png",
+ date => DateTime->now()->epoch,
+};
+my $entry2 = {
+ id => 2,
+ fulltext => "hello dolly how's it goin dolly",
+ image_url => "http://myimage.com/new.png",
+ date => DateTime->now()->epoch,
+};
+my $entry3 = {
+ id => 3,
+ fulltext => "I'm a swimmer bitch",
+ image_url => "http://myimage.com/new.png",
+ date => DateTime->now()->epoch,
+};
+#our $schema = JournalApp::Schema->connect( 'dbi:SQLite:./journals.db', '', '');
+our $schema = JournalApp::Schema->connect( 'dbi:mysql:database=journal;host=localhost;port=3306', 'journal_user', 'journal_password', {
+ quote_names => 1
+});
+
+sub test_remove_from_db{
+ #delete by id
+ my $journalentry = $schema->resultset('Journal')->find({ id => $entry->{id} });
+
+$journalentry->delete();
+}
+
+
+
+sub test_get_entry_by_date{
+ my $res = $schema->resultset('Journal')->search({
+ -and => [
+ date => { '>', DateTime->now()->epoch - 3600 * 24 * 2 },
+ date => { '<=', DateTime->now()->epoch },
+ ]
+ }, {
+ order_by => "date"
+ }
+ );
+ foreach my $row ($res->all){
+ print Dumper $row->id; #so it just didn't find anything? looks so yeah just needed <=
+ }
+
+}
+
+sub test_add_journal_entry{
+ my $entry = shift;
+ my $journalentry = $schema->resultset('Journal')->create($entry);
+ if ($journalentry){ print "added sucessfully\n"} else { "add failed\n" };
+ return $journalentry;
+}
+
+#how do I connect?
+
+sub main{
+ test_add_journal_entry $entry1;
+ test_add_journal_entry $entry2;
+ test_add_journal_entry $entry3;
+# test_get_entry_by_date;
+# test_remove_from_db;
+}
+main();
diff --git a/sphinxtest.pl b/sphinxtest.pl
new file mode 100644
index 0000000..3ec4f14
--- /dev/null
+++ b/sphinxtest.pl
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+use Data::Dumper;
+use Sphinx::Search;
+
+$sph = Sphinx::Search->new();
+
+$results = $sph->SetMatchMode(SPH_MATCH_ALL)
+ ->SetSortMode(SPH_SORT_RELEVANCE)
+ ->Query("dolly");
+print Dumper $results;