Skip to content

Comments

[4.0] com_finder: add search statistics#20681

Merged
wilsonge merged 17 commits intojoomla:4.0-devfrom
Hackwar:j4finder_log
Jul 7, 2018
Merged

[4.0] com_finder: add search statistics#20681
wilsonge merged 17 commits intojoomla:4.0-devfrom
Hackwar:j4finder_log

Conversation

@Hackwar
Copy link
Member

@Hackwar Hackwar commented Jun 6, 2018

Smart Search right now has no own logging, but instead uses the crappy logging of com_search, which itself is from Mambo times... The logging of com_search only logs the search term and the number of times that it was searched for and while there is an idea that it should log the statistics separately for both com_search and com_finder, it can't even distinguish between the two...

Anyway, this PR is based on issue #17437 and for now immitates the logging of com_search. In the component configuration I renamed the option to enable the logging to something that is a bit more descriptive. Then I added a new table for the logging data and in that table we now store the search term, the query object, the number of times this specific search was executed (including the filter settings), the number of given results for this and an md5sum to compare searches easily.
In the backend we have a new view, copied over from com_search mainly and updated to com_finder, that displays the statistics. At the top we have a button to reset these stats.

This PR implements the statistics that are part of com_search in com_finder, so that we can drop com_search and I would call this PR ready for now. In a second step, I would like to improve the FinderIndexerQuery class and the display of the stats to also display the filters of that search query and the language. But to be honest, I don't know how to display this nicely right now and I wanted to get this PR out there. So that would be part of another PR.

@alikon Can you check if I did the Postgres queries right? I didn't test those and just modeled them after the other queries that we have so far.

This removes a blocker for #20637

COM_FINDER_ITEM_X_ONLY="%s Only"
COM_FINDER_ITEMS="Content"
COM_FINDER_LOGGING_DISABLED="Gathering statistics disabled. Enable it in the Options."
COM_FINDER_LOGGING_ENABLED="Gathering statistics enabled"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a period at the end - however I am not sure we even need to display this notice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Since search logging could be pretty resource intensive, it doesn't seem like the worst idea to have that notice. We have this in the current com_search statistics, too. However I'm open for change requests. Should I remove this notice?

Hackwar added 2 commits June 12, 2018 11:49
…4finder_log

# Conflicts:
#	administrator/components/com_finder/sql/install.postgresql.sql
#	administrator/components/com_finder/sql/uninstall.mysql.sql
#	administrator/components/com_finder/sql/uninstall.postgresql.sql
@carlitorweb
Copy link
Member

carlitorweb commented Jun 18, 2018

I got this on the frontend:

Warning: count(): Parameter must be an array or an object that implements Countable in ..components\com_finder\View\Search\HtmlView.php on line 163

{
$canDo = $this->canDo;

ToolbarHelper::title(\JText::_('COM_FINDER_MANAGER_SEARCHES'), 'search');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you use JText for all strings. Why not use the new Text class?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It honestly doesn't matter either way right now if namespaced or aliased global classes are used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I know, that is why I ask. Thank for answer

@Hackwar
Copy link
Member Author

Hackwar commented Jun 18, 2018

This is mainly code copied from current com_search. Is it required that all of this is updated to the latest code or can we keep it the way it is right now and merge this?

@carlitorweb
Copy link
Member

I know you wrote, you will work more in this in other PR, but you can update the code with this move, and then work more easily in the update you want to do. No problem, if you prefer to wait.

@Hackwar
Copy link
Member Author

Hackwar commented Jun 18, 2018

@carlitorweb Please make sure that you have the latest version of 4.0-dev before applying this PR. It seems as if you don't have the latest updates that I did to com_finder lately.

@carlitorweb
Copy link
Member

Yes, I have the last version of 4.0-dev branch. No problem with that.
After i applied the last change, i got this:
Argument 1 passed to Joomla\Component\Finder\Site\Helper\FinderHelper::logSearch() must be an instance of Joomla\Component\Finder\Site\Helper\FinderIndexerQuery, instance of FinderIndexerQuery given, called in ..components\com_finder\View\Search\HtmlView.php on line 163

@carlitorweb
Copy link
Member

carlitorweb commented Jun 18, 2018

By the way, now I have the option working well, in the admin side. No more the message I had before. Sorry for this, was a mistake when I merge you PR

@Hackwar
Copy link
Member Author

Hackwar commented Jun 19, 2018

Sorry, a typo-fix was not commited. Fixed that one. Please test again. 😉

@carlitorweb
Copy link
Member

I still got:
Warning: count(): Parameter must be an array or an object that implements Countable in ..components\com_finder\View\Search\HtmlView.php on line 163

The statistic works fine. But as you can see, the Results column only show 1, because the warning I put you above.

screenshot_20180619170512

@carlitorweb
Copy link
Member

Also, every time you enter in the Statistics view the message Notice - Gathering statistics enabled show up. I suggest to you if the option is On no show this message, is unnecessary in my opinion

<field
name="search"
type="text"
label="COM_FINDER_SEARCH_IN_PHRASE"
Copy link
Contributor

@Quy Quy Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing language string. label and description have the same constant.

@Hackwar
Copy link
Member Author

Hackwar commented Jun 20, 2018

@carlitorweb Since the statistics gathering can potentially create a lot of entries in the table, there should be a notice either way, both when it is on and when it is off. That was at least the reasoning for this in the logging in com_search.

@Quy fixed.

@Hackwar
Copy link
Member Author

Hackwar commented Jun 20, 2018

@carlitorweb I can not confirm that error message. Please don't use the pulltester for this.

@carlitorweb
Copy link
Member

Thank @Hackwar . Yes, I just end the test without patchtester and no get the warning. Sorry for boring with this, I just start to get the idea when use or not the patchtester

@carlitorweb
Copy link
Member

I have tested this item ✅ successfully on 8ed03d7


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20681.

@Quy
Copy link
Contributor

Quy commented Jun 21, 2018

Fix year in filename 4.0.0-2918-06-06.sql

/**
* Methods supporting a list of search terms.
*
* @since __DEPLOYED_VERSION__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__DEPLOY_VERSION__

* @param MVCFactoryInterface $factory The factory.
*
* @see \Joomla\CMS\MVC\Model\BaseDatabaseModel
* @since 4.0
Copy link
Contributor

@Quy Quy Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__DEPLOY_VERSION__ Repeat below.


// Log the search
SearchHelper::logSearch($this->query->input, 'com_finder');
FinderHelper::logSearch($this->query, count($this->total));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->total is an integer thus the warning message below:

Warning: count(): Parameter must be an array or an object that implements Countable in \components\com_finder\View\Search\HtmlView.php on line 163

@Hackwar
Copy link
Member Author

Hackwar commented Jun 21, 2018

@Quy fixed the bugs.

@carlitorweb
Copy link
Member

Then, my local environment no was so crazy when I had this warning ;) .

@carlitorweb
Copy link
Member

All work ok now.
screenshot_20180626154336

@carlitorweb
Copy link
Member

I have tested this item ✅ successfully on 780205e


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20681.

@TobsBobs
Copy link

TobsBobs commented Jul 7, 2018

screen shot 2018-07-07 at 15 47 32

@TobsBobs
Copy link

TobsBobs commented Jul 7, 2018

I have tested this item ✅ successfully on 7eeab91


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20681.

@ghost
Copy link

ghost commented Jul 7, 2018

@carlitorweb can you please retest?

@carlitorweb
Copy link
Member

I have tested this item ✅ successfully on 7eeab91


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20681.

@ghost
Copy link

ghost commented Jul 7, 2018

Ready to Commit after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jul 7, 2018
@wilsonge wilsonge merged commit f41772c into joomla:4.0-dev Jul 7, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jul 7, 2018
@zero-24 zero-24 added this to the Joomla 4.0 milestone Jul 7, 2018
`hits` INT(11) NOT NULL DEFAULT '1',
`results` INT(11) NOT NULL DEFAULT '0',
UNIQUE INDEX `md5sum` (`md5sum`),
INDEX `searchterm` (`searchterm`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index has to be limited to the first 191 characters. See issue #21235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants