Hi, is there any method to fetch the total number of artists grouped by a country?
* Hi, is there any function defined to fetch the total number of artists grouped by a country?
mayhem[m] joined the channel
mayhem[m]
holycow23[m]: I personally don't know of one, but I suspect that if it does exist in the spark world, lucifer would know.
monkey[m] joined the channel
monkey[m]
<lucifer[m]> "monkey: sure i can create a..." <- Great, some help would be very helpful, thank you :)
I got the SSE endpoint working and sending updates. The part I need help with is somehow consuming incoming listening-now listens for a specific person, and how to set that up as a generator function for the SSE endpoint.
Let me upload the code I have for now...
holycow23[m]
<BrainzGit> "[listenbrainz-server] granth23..." <- ansh: could you please review this PR
Currently sleeps 5 seconds before checking the playing-now again, for testing only.
I struggled trying to figure out how to consume the RMQ channel, didn't get it to work. I figured this would be a good time to pass the baton and learn from your implementation
lucifer[m]
holycow23: its not a function but yes that data is available in a table you can join to. what's your use case?
monkey: i saw your latest commit in the widgets branch but i have a feeling it might not work, because as long as the sse request is running uwsgi won't be able to take up another request for processing. so 10-20 widgets rendering would block the server.
also one more thing, sse has a limit of 6 connections per site per browser.
monkey[m]
Oh...
Well, that's unfortunate, then. Do you think I should go back to a timed polling system on the client?
htmx seems to support websockets but not socket.io
we are using socket.io which is a wrapper around websockets and provides some additional capabilities on top of it. but yeah try using it and if you face issues let me know and i can try to help fix it.
monkey[m]
Cool, I'll have a look. Although I think I'll have the same questions: How does one connect to the WS feed for a specific user?
on the connection start, you emit a message with the username to add a user's feed to your connection. then you monitor it using the playing now events.
the WS feeds already exist so you only need frontend side to connect properly. i am not sure if we can connect properly without the socket.io extension but try it and let me know. otherwise i'll to find a work around.
monkey[m]
lucifer: I think this is a different mechanism than what I am trying to achieve. I'm trying to do all the templating and rendering on the server, and send rendered HTML fragments to the client.
So I'd like to avoid the type of mechanism we have for the metadataviewer, where we render everything on the client.
lucifer[m]
monkey: yes i understand that but do you want constant updates or just show the playing now listen at the time of server rendering?
monkey[m]
What I'm looking for is how to consume incoming listens for the user on the server-side, then I'll try to set up the fragment update mechanism using WS + HTMX>
SO not connecting to the same WS feed I suppose
The initial rendering of playing now listen is all working fine already, that's sorted.
I do want constant updates when a new listening-now comes in, if we can
lucifer[m]
right so at that point the code to consume the playing now listens would run on the client side no?
monkey[m]
But I could try to have the client do regular polling if that's easier than sending updates from the server
lucifer[m]
since the initial render on the server side has already completed.
monkey[m]
lucifer[m]: No, it would be consumed on the server, rendered using jinja templates, and the rendered HTML will be sent to the client
(i.e. no the initial playing-now WS message)
not*
lucifer[m]
i see and how would you send this rendered html to the client?
monkey[m]
So currently that's done with SSE, but with all the new info I suppose we'll
ditch that.
lucifer[m]
ah okay got it.
so instead of the json listen payload, you want a html payload created from the json
monkey[m]
So I guess setting up a new WS connection (at that point, doesn't need to be socket.io maybe?) and use HTMX to connect to an update endpoint which will send the HTML fragment
Yes
lucifer[m]
that shouldn't be hard, we can create a new WS room/endpoint
can you just test one thing, somehow log the json payload in htmx and see if its ws library works fine with our websockets setup.
if that works, i can setup a new endpoint for you to test. otherwise we'll first have to make the connection work.
monkey[m]
Well, I still need help with setting up the json payload consumer
One sec
lucifer[m]
sure
monkey[m]
OK, understood better now :)
I'll try to set up the HTMX code to hit our existing WS/socketi.io endpoint, see what happens
lucifer[m]
okay i don't it will work. htmx has custom event names that need to be defined on our server.
i'll try to set it up later today and try to make it work.
Kladky has quit
Kladky joined the channel
Kladky has quit
Kladky joined the channel
Kladky has quit
holycow23[m]
<lucifer[m]> "holycow23: its not a function..." <- I was working on a [ticket](https://tickets.metabrainz.org/projects/LB/issues/LB-1777?filter=allopenissues&orderby=created+DESC%2C+priority+DESC%2C+updated+DESC) so wanted the count in that
BrainzBot
LB-1777: Artist origin map "play something from this country"
lucifer[m]
holycow23: i see, can you tell what's your plan is to implement it? i don't think you'll need spark for it.
also mayhem might want to work this through LB radio so it might be better to add country support to LB radio if missing and then you only need to create a prompt.
monkey: polling the playing now endpoint is pretty efficient since it only queries redis.
holycow23[m]
lucifer[m]: I didn't intend to use spark, but if needed will have to make an API/function to retrieve the count for a country, which I will call everytime the stats are loaded
lucifer[m]: Country is already supported by radio and thus the LB-Radio side and prompt work is already done
monkey[m]
lucifer[m]: I think this would probably be hitting the widget endpoint that renders the HTML fragment instead, but maybe it could be improved in the same way I used the socket.io event, i.e. hit the plyaing-now endpoint, parse the response, compare if it is the same trans_name, otherwise trigger an event to reload the fragment...
mayhem[m]
there is country support in LB Radio. play random recordings from a country.
lucifer[m]
monkey: yes that sounds good to me
i think that is simplest for now.
monkey[m]
We're assuming it is better than loading the JS for socket.io and using a long-lived WS connection, then?
OK
Thank for the assist! No more need to consume the RMQ message on the server then, simpler to set up.
lucifer[m]
holycow23: i see, how do you intend to use the total artists count? anyway if you want to use it here then we'll have to create a LB metadata or labs api query for that.
monkey[m]
Shame about SSE though, that seemed like a really nice solution
holycow23[m] uploaded an image: (20KiB) < https://matrix.chatbrainz.org/_matrix/media/v3/download/matrix.org/igaKlWpNIaVQWorYbDAVyomR/image.png >
lucifer[m]
it is a nice solution yes, but i don't think it is meant for this use case.
monkey[m]
Apparently HTTP/2 removes the issue with 6 concurrent connections (defaults to 100)
lucifer[m]
oh i didn't know that, that's great.
holycow23[m]
holycow23[m]: The mockup prepared by aerozol has a total artist count from the country
if you face any issues, let me know and i'll help out
yano joined the channel
reosarevok[m]
aerozol, bitmap: MBS-13984 seems like a reasonable complaint to me - not sure what would be the best way to deal with this, do you have a preference from the suggested options?
"not show them at all", "show them collapsed" both sound good to me, potentially. I don't think it's the end of the world the way it is now, but still gets a bit silly :)
holycow23[m]
<lucifer[m]> "so forget the labs api link..." <- cool will look into it
if you cannot setup the dump, i can create the endpoint for you
holycow23[m]
I will give it a try
How do I use the dump?
And I assume I need to go ahead with admin/configure with alt-db-only-mirror
s//`/, s//` to just use the db not the website/
<lucifer[m]> "if you cannot setup the dump..." <- And I assume I need to go ahead with `admin/configure with alt-db-only-mirror` to just use the db not the website
lucifer[m]
Yes
holycow23[m]
okay
jasje[m] has quit
bitmap[m] joined the channel
bitmap[m]
<reosarevok[m]> ""not show them at all", "show..." <- my thought would be to hide them entirely (I've never even seen these before since I use the inline mode, and they aren't shown inline for some reason?) but maybe wait for more feedback on the ticket
reosarevok[m]
I think we hide a bunch of things online we do show on the bottom
Inline even :D
yano has quit
bitmap[m]
hmm, well we do have an isIrrelevantLinkType util but it's called from both places. only the inline code skips urls though. there might be other differences I'm missing
reosarevok[m]
Hmm, ok
Let's see what aerozol thinks (any other opinions welcome!)
yano joined the channel
yano has quit
yano joined the channel
julian45[m] joined the channel
TOPIC: MetaBrainz Community and Development channel | MusicBrainz non-development: #musicbrainz | BookBrainz: #bookbrainz | Channel is logged and not empty as it is bridged to IRC; see https://musicbrainz.org/doc/ChatBrainz for details | Agenda: Reviews, ChatBrainz downtime
TOPIC: MetaBrainz Community and Development channel | MusicBrainz non-development: #musicbrainz | BookBrainz: #bookbrainz | Channel is logged and not empty as it is bridged to IRC; see https://musicbrainz.org/doc/ChatBrainz for details | Agenda: Reviews
rustynova[m] joined the channel
rustynova[m]
Kinda want some advice on this. Critiquebrainz uses oauth for user api requests, meaning I need to securely store the app tokens. However, how can I do that in an user script? Should I just give up and let it in plain text?