Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track internal search queries #242

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

florianbrinkmann
Copy link
Member

@florianbrinkmann florianbrinkmann commented Mar 18, 2023

This PR:

  • ensures search queries are stored in the DB (lowercased, and never with a trailing slash)
  • Adds a Statify_Dashboard::parse_target() method that is called for the targets list in the widget. It makes sure the search query items are not just displayed as /?s=[…]

Looks like this:

Bildschirm­foto 2023-03-18 um 14 09 48

Closes #220

inc/class-statify-frontend.php Outdated Show resolved Hide resolved
inc/class-statify-dashboard.php Outdated Show resolved Hide resolved
inc/class-statify-frontend.php Outdated Show resolved Hide resolved
@Zodiac1978
Copy link
Member

Have you discussed about creating an own section for this instead of adding this data to the "views" section?

@stklcode
Copy link
Contributor

I didn't (maybe other parts of the team did). But a dedicated section seems like a good idea and might integrate well into the planned extended evaluation features. Should be removed from the pages view then or maybe just grouped together as "Search".

@florianbrinkmann
Copy link
Member Author

Didn’t think about adding an own section, but like the idea, then we also do not need the Search query: prefix

@florianbrinkmann
Copy link
Member Author

Changed it so that the search queries are displayd in its own list

Screenshot of the Statify widget with the new area for search queries

views/widget-front.php Outdated Show resolved Hide resolved
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

* @version 1.4.0
* @since 0.1.0
* @since 1.4.0
* @since 2.0.0 Add search queries to `$data` array.
Copy link
Member

Choose a reason for hiding this comment

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

Is this common to add a "changelog" like this to PHPDoc? And now we also have three @since and no @version anymore. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we used the @version wrong, if I am right, it is ment to set versions for APIs and similar (https://docs.phpdoc.org/guide/references/phpdoc/tags/version.html#version), and you can use multiple @since (https://docs.phpdoc.org/guide/references/phpdoc/tags/since.html#since)

Copy link
Contributor

@stklcode stklcode Mar 20, 2023

Choose a reason for hiding this comment

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

Yep, @since is commonly used for changelog purposes, mostly changes to method signature or high-level behavior (at least helpful on public API that can be quite helpful to have this information on hand in the IDE)
@version is meant for semantic changes and the state of the functionality.

Multiple of either one don’t make much sense, because they yield barely any information, just “something was done here“.

Something like this would be more or less meaningful:

@since 1.0 introduced (if this is left empty, the natural assumption would be the same)
@since 1.1 return boolean result instead of void
@since 1.2 make parameter $foo optional with default 42

@version 1.1

I personally often omit the version tags, if there is no real need for that. The since-tags often help even in the same project to see why a method is used in a non-optimal way or similar. In such cases the hint “method was updated in 1.2“ and “we use it since 1.1“ immediately presents a valid reason, so we don’t have to guess what someone may have thought here.

Btw. that is also done in WP core and the changelogs are rendered in the reference articles, e.g.: https://developer.wordpress.org/reference/functions/wp_parse_url/#changelog

Copy link
Member

Choose a reason for hiding this comment

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

"Since" we only use it on some functions and we don't even have a real "public API", would we even mind keeping these @since version numbers up to date?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, a public method is a public method and there are some recommendations out there for things like workarounds or custom triggers that call some of these. Some snippets given by ourselves in the support forums. Documenting API changes enables users of those to potentially migrate their logic without opening another support request, if changes are not self-explaining.

I agree, the majority of our code is designed for internal use and only exposed public for hooks etc.

But as with every project, that’s yet another part of documentation that might get out of sync over time. Though it’s probably one of the easier parts, as old annotations typically never become wrong, so we only have to append another one-liner, if necessary.

Comment on lines +51 to +53
<?php for ( $i = 0; $i < $limit; $i++ ) { ?>
<tr class="placeholder"><td colspan="2">&nbsp;</td></tr>
<?php } ?>
Copy link
Member

Choose a reason for hiding this comment

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

Do I get this right, that you first create a table with empty <tr> tags and then fill/replace them using JavaScript? Why not generate the <table> in JavaScript instead?

Copy link
Member

Choose a reason for hiding this comment

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

OK, you do just the same as with the other tables 🙈

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

Successfully merging this pull request may close these issues.

Count internal search queries
4 participants