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

Mount multiple streams #53

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Conversation

thekeele
Copy link
Owner

@thekeele thekeele commented Sep 15, 2020

closes #13

</div>

<div class="column">
<div class="box">
<h1 class="title has-text-centered">Tweet Type</h1>
<div class="buttons are-large">
<button class="button is-light is-fullwidth is-outlined <%= is_selected("hourly_text", @hourly.filter.type, @hourly.filter.weight) %>" phx-click="hourly_text">Text</button>
<button class="button is-light is-fullwidth is-outlined <%= is_selected("hourly_text", hourly.filter["type"], hourly.filter["weight"]) %>" phx-click="text" phx-value-stream="<%= stream %>" phx-value-interval="hourly" phx-value-filter="type">Text</button>
Copy link
Owner Author

Choose a reason for hiding this comment

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

We can add phx-value-* to send data to the phx-click events.

For example phx-value-interval="hourly" adds %{"interval" => "hourly"} to the params in the handle_event callback.

I was able to remove a lot of duplication by sending specific values.

@thekeele
Copy link
Owner Author

The handle_info and handle_event callbacks should be good to go.

The selection still needs work.

@rcehemann
Copy link
Collaborator

here we go 🚀

@rcehemann
Copy link
Collaborator

image

Something blew up after removing all streams then adding one back

@rcehemann
Copy link
Collaborator

data is getting overwritten in the callbacks, I'll see if i can figure out what's going on but no guarantees

@rcehemann
Copy link
Collaborator

I can't figure out what's going on. There must be some callback that isn't aware of which stream's data it's getting or something. From staring at logging messages, the data accumulates as long as it's receiving new tweets of the same type... but when the tweet type changes it seems to reset. This doesn't happen when only one stream is active.

<div>
<p class="heading">Stream</p>
<p class="title"><%= String.upcase(stream) %></p>
<%= if Enum.count(@streams) > 0 do %>
Copy link
Owner Author

Choose a reason for hiding this comment

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

You can pattern match and avoid the count here.

if @streams == [] do
  # no streams
else
  # show stats

Copy link
Owner Author

Choose a reason for hiding this comment

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

The match?/2 macro is an alternative to the above. Whatever reads better to you.

if match?([], @streams) do

@thekeele
Copy link
Owner Author

I'm pretty sure I know what's going on here. There's no bug, LiveView is working as expected 😀

LiveView updates whenever a key is assigned to the socket. With the current changes all the data is stored under the streams key so on each message the entire page is effectively changed.

I'm going to have to do some more research on LiveView and figure out what we can do here.

@thekeele
Copy link
Owner Author

I'm gonna try out another approach (fancy liveview stuff) on another branch. Depending on how that goes, we may not use this branch.

@rcehemann
Copy link
Collaborator

I'm gonna try out another approach (fancy liveview stuff) on another branch. Depending on how that goes, we may not use this branch.

Sounds good man

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

Successfully merging this pull request may close these issues.

Sentiment chart for each active stream
2 participants