« [Plugin] Awards
[Plugin] User Mentions v1.0 (9th March 2013)

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #15, on March 9th, 2013, 06:11 PM »
Quote from Dragooon on March 9th, 2013, 02:27 PM
Actually mentions would fail absolutely miserably for usernames with a space, I gotta figure something out for this.
Okay, fixed this part. Had to make the whole name matching thing a bit slower and quite more complicated, but it's quite robust now. Since this only happens after a post is created, a bit of a performance hit shouldn't matter much (documented my algorithm on the function's docblock if anyone's interested).
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #16, on March 9th, 2013, 09:54 PM »
And I ran into even more issues, names with punctuations would work but what if someone does "@Nao: Would it work?", the colon would screw it up and it'll be an even bigger pain (and this happens fairly commonly in forums). So I decided to split the strings up even further, instead of splitting by spaces it now splits by everything that's not a alphanumeric character (regex \w boundary) and maks combinations like first part, first and second part, first, second and third part and so on. A stupid (and improbable) sentence like
Code: [Select]
@Admin: This is perhaps a crude test, but how would @Maxwel do for the later project? I'm not entire sure if this'll work like the way it's supposed to.
@Maxwel: What do you think of the project itself? Care to elaborate on your findings? Perhaps add another prospect given by @Trish to @Soxell?
What about @-Lük-? How would this really work? Would it work? Or would it not work? Does't it require a massive amount of overhead for bear that shouldn't be born?
generates 66 combinations in about 20ms, which is then queried against real_name in members table. It's definitely a hit on performance but shouldn't be by much.
The way it's meant to be

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #17, on March 9th, 2013, 10:53 PM »
Suggestion: take the first part, htmlspecialchars it then query members LIKE 'firstpart%', then sift the results post-query. It may be faster for the worst case scenarios.

Also, I'm thinking there's a bug in the flexbox on Chrome. I'll post a screenshot shortly.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #19, on March 10th, 2013, 05:59 AM »
Well, that's where it gets complicated. column IN (value1, value2, value3) ultimately parses as (column = value1 OR column = value2 OR column = value3), which is not efficient.

Now, there is an index on real_name, but I'm not sure how useful the index will be. Create a table with 1000 rows in it and try the 66 permutations on it with an EXPLAIN on the query to see how that ultimately parses out, but I'd be willing to bet it probably will be Using where, not Using index. If it's Using where, it's going to be table scanning anyway just as it would with a LIKE, bearing in mind you only need to do a like against the first part if I've understood you correctly.

If in doubt, try it and benchmark it. I'm only guessing based on what's been described thus far, but I wouldn't expect the index to be that useful.

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #20, on March 10th, 2013, 06:11 AM »
I'll do some benchmarking on Monday or Tuesday, until then I'm leaving it as is. Its working fine atleast.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #22, on March 11th, 2013, 10:12 AM »Last edited on March 11th, 2013, 08:52 PM
Looks like the index is kicking in?

Code: (EXPLAIN) [Select]
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: smf_gallery_members
         type: range
possible_keys: real_name
          key: real_name
      key_len: 767
          ref: NULL
         rows: 44
        Extra: Using where*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: smf_gallery_members
         type: range
possible_keys: real_name
          key: real_name
      key_len: 767
          ref: NULL
         rows: 44
        Extra: Using where*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: smf_gallery_members
         type: range
possible_keys: real_name
          key: real_name
      key_len: 767
          ref: NULL
         rows: 44
        Extra: Using where*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: smf_gallery_members
         type: range
possible_keys: real_name
          key: real_name
      key_len: 767
          ref: NULL
         rows: 44
        Extra: Using where*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: smf_gallery_members
         type: range
possible_keys: real_name
          key: real_name
      key_len: 767
          ref: NULL
         rows: 44
        Extra: Using where

EDIT: This is actually on a SMF's member table with ~22k records, but I don't think that should make a difference

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #23, on March 11th, 2013, 02:02 PM »
I only dread how big the index is going to be for that table (since the index size is 3/4 of a KB PER ROW), but it's still relying primarily on the where to sift.

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841

Nao

  • Dadman with a boy
  • Posts: 16,063
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #25, on April 4th, 2013, 09:14 AM »
Thought I should mention... (Ah, ah.)
(Where do I post my updated files anyway..?)

Yesterday I fixed the silly bug where doing @Nao on a single line without any other punctuation would fail to 'detect' it.
For the record: it was due to the strip_tags call. It can be called, but it should add an exception parameter of '<br>'. Otherwise, multiple lines are put together without any separator, and you know what that means... Something like @NaoSecond line.

agent47

  • Now I see the changes you're talking about.
  • Posts: 115
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #26, on April 4th, 2013, 09:35 AM »Last edited on April 4th, 2013, 09:55 AM
This is so so awesome man! You have no idea how many times I've wanted to this on forums. So cool @Dragooon
Although I do have a couple of questions; do you plan on making this work on 'quick reply' too or does that complicate things?
Plus I also noticed that upon mentioning usernames, it seems to be duplicating entries on the ajax drop-down list.
Also, what happens when a members' real name/username differs from his/her display name? (Is that what causes the duplicate entries; one's the real name/username and the other is the display name?)

Nao

  • Dadman with a boy
  • Posts: 16,063
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #27, on April 4th, 2013, 11:00 AM »
Didn't you notice earlier...? It's been installed for a couple of weeks at least...

Also, now there's this strange bug where I actually get a proper reference when doing @NaoSecond..?! Shouldn't it be ignored..?

Yes, I plan to have it work on quick reply, too, but I won't make any promises. The problem is mostly with loading extra files on topic load, which is always annoying. (I'm considering loading these scripts only when first clicking Quick Reply, though...)

Only the display name is taken into account. That's how Dragooon programmed it, and I don't have plans to change it.
The only place where you can see a user name (login) anyway is in the profile page...

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #28, on April 4th, 2013, 11:06 AM »
Quote from Nao on April 4th, 2013, 09:14 AM
Thought I should mention... (Ah, ah.)
(Where do I post my updated files anyway..?)

Yesterday I fixed the silly bug where doing @Nao on a single line without any other punctuation would fail to 'detect' it.
For the record: it was due to the strip_tags call. It can be called, but it should add an exception parameter of '<br>'. Otherwise, multiple lines are put together without any separator, and you know what that means... Something like @NaoSecond line.
@Nao I have no idea how that got triggered, but if you'd notice my previous post I had fixed this bug about a week ago (along with a couple others), they're in my repository. You can post a diff if they're something more than that bug fix and I'll add them into my repository.
Posted: April 4th, 2013, 11:03 AM

Oh and is markReadForNotifier disabled for this site? It isn't marking my notifications as read when I view this topic.

Nao

  • Dadman with a boy
  • Posts: 16,063
[Plugin] Re: User Mentions v1.0 (9th March 2013)
« Reply #29, on April 4th, 2013, 11:08 AM »
Well, looks like it's working now, without changes... Something like @NaoSecond line.

Ah, your git repo... I don't tend to visit github often... :whistle:

Right now, I'm fighting with my caret position hack for your mentions popup. It's... quite interesting. I dunno why, this morning I decided I wanted to have it pixel perfect, and still überfast. I managed to do it, but then I realized my pixel-perfect code issues were mostly down to errors on my side, hmm...