Comments (22)
I think this is an easy fix; it looks like a change was made in 2019 that changed the sort order, but then it was changed back, and the field name to sort on was changed, and it was never updated again to sort with the new field name. Testing a fix now...
from mastodon.
Well, this is rather complicated...
The sorting function is set up to sort from values in the tags sql table, which does not store the actual occurrence count. The "uses this week" value is an aggregate value generated at runtime from recent tag history. Sorting was set up to use a "score" which is built over time, and is now recorded as "max_score"
So we could easily redo the sorting to use the max_score but that does NOT produce a sorted list by "uses this week"; for example "mastodogs" appears above "mastodon" because at some point mastodogs got super popular and bursted above the average usage of 'mastodon'.
I've got a version deployed that feels a bit better but still isn't great. It'd be a substantive refactor to actually sort by "uses this week" unfortunately.
from mastodon.
This is the tags table schema:
---------------------+-----------------------------
id | bigint
name | character varying
created_at | timestamp without time zone
updated_at | timestamp without time zone
usable | boolean
trendable | boolean
listable | boolean
reviewed_at | timestamp without time zone
requested_review_at | timestamp without time zone
last_status_at | timestamp without time zone
max_score | double precision
max_score_at | timestamp without time zone
display_name | character varying
And this is the current deployed sorting code for Urusai as of now:
def search_for(term, limit = 5, offset = 0, options = {})
stripped_term = term.strip
query = Tag.listable.matches_name(stripped_term)
query = query.merge(matching_name(stripped_term).or(where.not(reviewed_at: nil))) if options[:exclude_unreviewed]
query.order(Arel.sql('max_score ASC, name ASC'))
.limit(limit)
.offset(offset)
end
Currently checked in upstream is:
query.order(Arel.sql(length(name) ASC, name ASC'))
.limit(limit)
.offset(offset)
from mastodon.
Well, the real answer here is to just do what's intended to get better autosuggestion/search: set up elasticsearch integration.
So that's what I'm doing :D
We can try to make this better too, if we want, but IMO it's low prio since there's a preferred solution
from mastodon.
Think this is worth reopening, doesn't seem fixed, even with elasticsearch :/
from mastodon.
from mastodon.
Oh just looked at the code snippet, you probably want to order by score DESC right? ASC would sort it least-to-most
from mastodon.
from mastodon.
Hmm... I'll see if I can mess around with it and see if I can figure something out. Seems weird because the current behavior seems correct on other hashtags, like this is exactly what I would expect:
from mastodon.
from mastodon.
Hashtag ordering seems to work fine on Megalodon... I wonder if this is just some weird edge case in the browser
from mastodon.
from mastodon.
Nope, it looks like the frontend is doing something weird... The request seems to return the hashtags in the right order. Wonder what's happening.
However... when redux gets updated, looks like they're out of order. Weird...
from mastodon.
from mastodon.
It looks like some kind of transformation gets applied before it gets put in redux, trying to figure out where this happens (which seems a bit weird, not like suggestions really need to be stored in global state...)
EDIT - Guessing it has something to do with this line. (app/javascript/flavours/glitch/reducers/compose.js
)
return mergeLocalHashtagResults(sortHashtagsByUse(state, tags.map(item => ({ ...item, type: 'hashtag' }))), token.slice(1), state.get('tagHistory'));
from mastodon.
This seems so weird... I can't seem to replicate the behavior in Node, even if I copy the behavior nearly line-for-line
The browser one starts correctly, but then ends incorrectly, and I have no clue why
from mastodon.
from mastodon.
Yup, reproduces in all browsers. Although I've got it reproducing in node now, so that's good! Maybe I was just copying it over incorrectly.
from mastodon.
Oh man, I figured it out. I'll file this bug with mastodon as well.
It only occurs if:
- You have used the hashtag in this browser, which puts it in your
tagHistory
. - The tag in your
tagHistory
matches (case sensitive) one of the suggested hashtags.
If both of these cases happen, it's supposed to promote it to the top, as it's a suggested hashtag which you have used before. However, the sorting algorithm is reversed, and case-sensitive, making it (inconsistently) demote it to the bottom.
from mastodon.
from mastodon.
Ahh, the bug appears to have been introduced in glitch-soc, I assume mastodon fixed it but glitch-soc never brought the fix over?
from mastodon.
from mastodon.
Related Issues (20)
- Boosts are only inserted into the public timelines on page refresh HOT 1
- Old posts sometimes inserted into the timeline HOT 8
- Add setting in Local/Federated timeline to hide boosts HOT 2
- Emojis in a linked status do not zoom
- [frontend-only] Option to combine similar notifications into a single notification HOT 5
- Allow for status action customization HOT 1
- Add a way to see who reacted to a post HOT 1
- The emoji picker is not forced within the screen bounds HOT 6
- Add ability to collapse reaction notifications (just like boost and favorite)
- custom emoji don't show in notifications
- Allow customization of number of visible lines in a collapsed status HOT 1
- Show full reaction counts on remote posts HOT 2
- Updates required to fix Linting
- [Wording] Consider either clarifying what "otaku" means or replacing the word with something less derogetory
- Bug: NoMethodError when accessing nil value in has_user_settings.rb (setting_flavour) HOT 1
- ArgumentError (missing keywords: :records, :associations) after update HOT 1
- Emoji Reactions not converting to Favourites on Vanilla Mastodon instances HOT 1
- mp3 uploads not playing HOT 1
- `ReferenceError: ReactIcon is not defined` on Vanilla Mastodon HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mastodon.