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

Ensure live status requests are always batched #4713

Merged
merged 11 commits into from
Jul 2, 2023

Conversation

pajlada
Copy link
Member

@pajlada pajlada commented Jul 1, 2023

Description

This makes sure live status requests are always batched, including the first one

Titles are also now always batched, and updated frequently rather than just randomly when we hover over the split header.

The display name of a channel is now also updated, if necessary, alongside the livestatus changes. Technically unrelated to the live status-ness but since we have that data in the same request, we might as well update it.

@pajlada pajlada force-pushed the feat/batch-stream-live-status-requests branch from bb9a845 to 204d18e Compare July 2, 2023 12:21
@pajlada pajlada marked this pull request as ready for review July 2, 2023 12:43
@pajlada
Copy link
Member Author

pajlada commented Jul 2, 2023

image

@pajlada pajlada changed the title Batch stream live requests Ensure live status requests are always batched Jul 2, 2023
@pajlada pajlada enabled auto-merge (squash) July 2, 2023 12:45
@pajlada pajlada merged commit 7652707 into master Jul 2, 2023
15 of 16 checks passed
@pajlada pajlada deleted the feat/batch-stream-live-status-requests branch July 2, 2023 13:52
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@@ -86,6 +86,12 @@ class Helix : public IHelix
std::function<void()> finallyCallback),
(override));

MOCK_METHOD(void, fetchChannels,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: invalid case style for function 'MOCK_METHOD' [readability-identifier-naming]

Suggested change
MOCK_METHOD(void, fetchChannels,
mockMethod(void, fetchChannels,

QStringList channelIDs;

{
std::unique_lock immediateRequestsLock(
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'immediateRequestsLock' of type 'std::unique_lock' (aka 'std::unique_lockstd::mutex') can be declared 'const' [misc-const-correctness]

Suggested change
std::unique_lock immediateRequestsLock(
std::unique_lock const immediateRequestsLock(

assert(!channelID.isEmpty());

{
std::unique_lock lock(this->channelsMutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'lock' of type 'std::unique_lock<shared_mutex>' (aka 'std::unique_lockstd::shared_mutex') can be declared 'const' [misc-const-correctness]

Suggested change
std::unique_lock lock(this->channelsMutex);
std::unique_lock const lock(this->channelsMutex);

}

{
std::unique_lock immediateRequestsLock(this->immediateRequestsMutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'immediateRequestsLock' of type 'std::unique_lock' (aka 'std::unique_lockstd::mutex') can be declared 'const' [misc-const-correctness]

Suggested change
std::unique_lock immediateRequestsLock(this->immediateRequestsMutex);
std::unique_lock const immediateRequestsLock(this->immediateRequestsMutex);

}
else
{
std::shared_lock lock(this->channelsMutex);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'lock' of type 'std::shared_lock<shared_mutex>' (aka 'std::shared_lockstd::shared_mutex') can be declared 'const' [misc-const-correctness]

Suggested change
std::shared_lock lock(this->channelsMutex);
std::shared_lock const lock(this->channelsMutex);

this->addMessage(builder.release());

// "delete" old 'CHANNEL is live' message
LimitedQueueSnapshot<MessagePtr> snapshot =
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'snapshot' of type 'LimitedQueueSnapshotchatterino::MessagePtr' (aka 'LimitedQueueSnapshot<shared_ptr>') can be declared 'const' [misc-const-correctness]

Suggested change
LimitedQueueSnapshot<MessagePtr> snapshot =
LimitedQueueSnapshot<MessagePtr> const snapshot =

// "delete" old 'CHANNEL is live' message
LimitedQueueSnapshot<MessagePtr> snapshot =
getApp()->twitch->liveChannel->getMessageSnapshot();
int snapshotLength = snapshot.size();
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'snapshotLength' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int snapshotLength = snapshot.size();
int const snapshotLength = snapshot.size();

// "delete" old 'CHANNEL is live' message
LimitedQueueSnapshot<MessagePtr> snapshot =
getApp()->twitch->liveChannel->getMessageSnapshot();
int snapshotLength = snapshot.size();
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]

            int snapshotLength = snapshot.size();
                                 ^

int snapshotLength = snapshot.size();

// MSVC hates this code if the parens are not there
int end = (std::max)(0, snapshotLength - 200);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'end' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int end = (std::max)(0, snapshotLength - 200);
int const end = (std::max)(0, snapshotLength - 200);

status->gameId = stream.gameId;
status->game = stream.gameName;
status->title = stream.title;
QDateTime since =
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'since' of type 'QDateTime' can be declared 'const' [misc-const-correctness]

Suggested change
QDateTime since =
QDateTime const since =

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.

None yet

1 participant