Gossamer Forum
Quote Reply
Improved Search Logger
Attached is a new version of the Search Logger. this has significant improvements over the old one.
  1. More compatible with Links' interrnal standard table structure
  2. 2.1 logic compatible
  3. Tracks both daily and total searches
  4. Can return daily totals
  5. Can return totals
  6. Can return the most recent hits
  7. Uses a function call <%Plugins::SearchLogger::Top_Keywords ('nn', 't|r|d')%> where 'nn' is the number of terms to return, and t,r,d stands for totals, recent, or daily hits where you can specify the # of terms to return.
  8. Delete old records from the admin by a date-older-than format.
  9. Copyrighted Freeware, no charge to use, but must credit the original sources ie: Gossamer-Threads & Pugdog Enterprises, Inc.


Once installed, it functions just as the original SearchLogger, but it maintains two tables. SearchLog and SearchLogDaily. The SearchLog table should still work with any globals you may have running off it. No guarantee, but it should -- as long as you are not using the ->get construct to call the records.

You use the plugin by inserting the function call into your template where you want the list of terms to reside.

<%Plugins::SearchLogger::Top_Keywords ('10')%>

Would return the 10 most search key words (same as if you used ('10', 't').

<%Plugins::SearchLogger::Top_Keywords ('10', 'd')%>

Would return the top 10 keywords for that day, starting at midnight (not a 24 hour span, a calendar day)

<%Plugins::SearchLogger::Top_Keywords ('11', 'r')%>

Would return the most recent 11 searches, even if they spanned several days.

If there are fewer than the requested number of records for the daily search, it returns only what it finds.

This new logic allows easy addition of other features, and I have a few I'm working on.

Known limitations are:
  • Daily totals reset at midnight, your server's time, can be potentially confusing. Need to expand this a bit.
  • Works with dynamic pages -- such as page.cgi, search, etc.
  • Static pages will have a 'snapshot' of the time they were created. I'm not sure how this could be expanded to allow an SSI call, other than moving that routine to a small .cgi script that can be included in the static page. I don't use, and never have, SSI, so I don't have any practical experience there.
  • HTML has to be edited in the .pm file because it's variable (not token) substitutions. I'll look at making that a parsed call, but that would mean additional overhead in the templates where the plugin function returns an array of values you have to loop through, like you do the links. In that case, output could be defined in your templates. It starts getting "messy" the more you try to do, and the whole goal was to create a _simple_ tag that would insert the top keywords easily. I guess, I could maybe (try?) to do something like <%Plugins::SearchLogger::Top_Keywords ('10', 't', 'noloop')%> and have it default to 'loop' (where you'd have to take the results and stick them in a <%loop%> construct to change the output format. ?? maybe.


Anyway... it works -- or seems to, with major bugs swatted. So let me know.



If you have SearchLogger installed, the best way to install this, is to open up MySQL Man, and go to the SQL Dump area. Select the 'dump specific tables' and select only the 'SearchLogger' table. Select don't write tables, and then select 'Use INSERT statements that name each column to be inserted. ' This will save the contents of the SearchLogger table. Named columns are _important_.

Once you are sure you have this file of data saved, you can _FULLY_ uninstall the SearchLogger program, upload this new version, then install this version.

Import your saved data from step one, by either loading from file or pasting into the SQL Monitor box. (Depends on how much you have in the file)

There should be _no_ problems with your current install! Nothing has been changed, other than a new SearchLogger.pm was written to your Plugins directory, and your Plugins.cfg was updated with the additional hooks for the admin.

To start to use the program, you follow the steps above.

To change the output, you can (pretty safely) edit the SearchLogger.pm file. The only line that would need to be edited is:

$output .= qq~ <LI><a href="$db_cgi_url/search.cgi?query=$term_q">$term</a> ~;

(ONLY edit the stuff between the ~ marks)

If you don't want the List format, you also need to delete the two lines:

$output .= '<UL>';

and

$output .= '</UL>';






PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.

Last edited by:

pugdog: Dec 29, 2001, 10:21 PM
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
Hi,

Very cool! Let me know if you want me to add it to the download area, and I'd be happy to do so.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Improved Search Logger In reply to
Alex,

Feel free to add to the downloads area. I just did this since people were asking for it, and it was a holiday weekend.

Anything I upload, feel free to move around. Downloads area, resource, area, etc.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
This is a very good plugin.

I wonder if your going to display the 'Count' & 'Results' for the page as we see in admin screen somehow??
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
Hey Pugdog, this is a great plugin... I only just found it today!

The plugin in the main plugin download area does not have your version of this, I reckon it should!!

One question, any way to get the list (I am doing top ten searches) to show number next to it?

1. Britany Spears
2. Perl
3. Links SQL
4 etc....

Instead of
  • Britany Spears
  • Perl
  • etc




Smile

Last edited by:

sooke: Apr 20, 2002, 11:47 PM
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
First of all, thanks for the updated plugin!!!


Unfortunately, there seems to be a very small quirk...

I just installed and clicked on "View Daily Logs". I received the following error:

A fatal error has occurred:

Invalid plugin function: view_daily at /www/cgi-bin/admin/admin.cgi line 208.

Please enable debugging in setup for more details.



This error seems to go away as long as the database has a logged search in it. The first search I did after installing, the error went away. Just thought you should know.

Sean

Last edited by:

SeanP: Apr 21, 2002, 1:37 PM
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
Hi Pugdog,

I have a problem where I reached 27 unique searches in my log, but all new searches are not added to the lists (daily or total). Yet the searches are coming up in the top 10 output.

I have tried purging, but nothing seems to clear.
Quote Reply
Re: [SeanP] Improved Search Logger In reply to
Thanks,

I actually forgot I wrote and released this (<G>, blush). Someone asked me about it, and I had no idea what they were talking about! Now I remember...

I'll try to swat this and add in a few extra features for the next release.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
Would displaying the latest searches instead of the first searches in the table be a simple matter of just swapping a DESC and a ASC in the SQL?
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
PugDog,

Would it be very difficult to make it so the plugin only logs page one (nh=1)? That way, you wouldn't get a search count for every page viewed within the results.

Sean
Quote Reply
Re: [SeanP] Improved Search Logger In reply to
Hi,

No, not hard at all (I think).

This is on my list, but it seems every time I find a window of time, I get blivited again. Last week, Tuesday, great grandma died very suddenly, right after my wife left her. They had spent the morning together, and by the time she got home, grandma was gone. No warning at all. (Of course she was 96...) Then she herself ended up in the hospital with severe chest pains on saturday. So, the past 2 weeks/10 days have been pretty non-productive.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
Ok,

Looking at the issue, Search.pm does not return nh= anything to the templates. It only returns 'next' which is already pre-parsed.

I've tried to figure out a template only type solution, but can't, since Search::query can be called from multiple places, not only the search.html

It *might* be possible to use a pre-hook on Search::query , and see if 'nh' is defined, and if it is, is it <2.

If it is, then set $IN->param('Log_Me') to '1'. You'd have to push onto this hash, since you need it carried through to the post_hook where the logging takes place.

Then, in the SearchLogger.pm file before you log anything, check to see

return if ($IN->param('Log_Me) == 1);



===



I'm still half asleep with a pounding stress headache, and my male Pekingese is doing a mating dance with my femal Sheltie (or trying to) on the hardwood floor so all I hear is a tap-tap-tap of toe-nails and a lot of grunting and wheezing (I know you wanted to know that....) ..... but the point is, if this looks like it will work, I'll try to update the plugin this way.

If someone has a better idea, I will check it out.

But the problem is, and if you look at <%GT::Template::dump%> there is no "flag" field like nh being passed into the templates any more, so without editing Search.pm (which would be non portable) you need to come up with a solution that will work _anywhere_ search is called.


...


Hmmm..... Now that I'm thinking about it... Search::query can be called from anywhere, the first time, but _only_ can be sent page 2, 3, etc from the search_results.html.

What about _reverse_ logic. Set a flag in the search_results.html template, (which _would_ be passed through all phases of the system, in the $IN hash), such that "Log_Me_Not=1".

<input type=hidden name=Log_Me_Not value=1>

Then in SearchLogger.pm's logging routine, add in,

my $log_me_not = defined $IN->param('Log_Me_Not') ? 1 : 0; ## prevents undefined errors/warnings
return && ($log_me_not == 1);

above the logging code.

====

Two choices. Try the second one first... it may actually work <G> (and if it doesn't, it's only two lines of code to remove or debug).

Just a programming note: When you set a flag, that you are going to test for, you really want to set it to some value, not '0'. So, using "Log_Me=0" is *not* a good way to do it. In this case, since we want to skip the log phase if we are not on page 1, we need to use a double negative logic "if not on page1, Log_Me_Not=1" so you have a parameter with a "set" value that will be passed, and not dropped along the way. "Log_Me_Not=0" will be true (undefined) on any page that isn't specifically set "Log_Me_Not=1" so anywhere else that search is called, the logging will occur.

.... Good Luck .... :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
Thanks Pugdog, I'll try your suggestions! I'm sorry to hear about your grandmother.

Sean

Last edited by:

SeanP: Jun 8, 2002, 10:45 AM
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
Pugdog,

Has there been another release of this plugin yet? Has this version been performing well for those who use it? I'm using the plugin available through the plugin download area but would like more features like this.

Thanks,

Craven
Quote Reply
Re: [craven32] Improved Search Logger In reply to
I use this version - but I think it needed a bit of modification to get certain parts working - like the page span. I'm not sure why it hasn't replaced the one in the download area?
Quote Reply
Re: [afinlr] Improved Search Logger In reply to
It doesn't make since to not replace the old version! I really like Links Sql but I wish the site was updated more often. It seems like there are a lot of great ideas and globals in the forums but not in the resources area. I wish they would sort these out and make it a little easier on those looking for mods.

Why hasn't this been moved to the download area?

Craven
Quote Reply
Re: [craven32] Improved Search Logger In reply to
By the way - here is my replacement for the pm file if you want to use it.

http://www.gossamer-threads.com/...i?post=252093#252093
Quote Reply
Re: [craven32] Improved Search Logger In reply to
Hi,

No, I'm in a swamp at the moment. Short two computers, running backups for 2 weeks now.

I have a lot of stuff to release, update, and work on, but just no time. I am trying to find some local kids who can help out a bit, take some of the load off me, but there just isn't enough of me to go around. There _is_ a good argument for cloning ;)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Improved Search Logger In reply to
I'll be redoing this plugin in the next week or two. If there are any other problems, please let me know.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.