Skip to content

Instantly share code, notes, and snippets.

@gregblake
gregblake / alternative.diff
Created August 7, 2020 12:48
Alternative Solution
diff --git a/components/connect-web-ui/src/components/ConversationTitle/EditRoomAudiencesForm.jsx b/components/connect-web-ui/src/components/ConversationTitle/EditRoomAudiencesForm.jsx
index c3977d1cb3..6d27c4610a 100644
--- a/components/connect-web-ui/src/components/ConversationTitle/EditRoomAudiencesForm.jsx
+++ b/components/connect-web-ui/src/components/ConversationTitle/EditRoomAudiencesForm.jsx
@@ -17,7 +17,8 @@ export const EditRoomAudiencesForm = ({ audience, hideAudienceForm, loadingLooka
const removeAudience = (id, fieldName) => {
onChange({
...audience,
- userIds: undefined,
+ id: undefined,
@gregblake
gregblake / wget.sh
Created August 6, 2020 10:36
wget webpacker-4.2.2.tgz returns a 200 locally
❯ wget https://registry.yarnpkg.com/@rails/webpacker/-/webpacker-4.2.2.tgz
--2020-08-06 06:28:08-- https://registry.yarnpkg.com/@rails/webpacker/-/webpacker-4.2.2.tgz
Resolving registry.yarnpkg.com (registry.yarnpkg.com)... 2606:4700::6810:1823, 2606:4700::6810:1723, 2606:4700::6810:1a23, ...
Connecting to registry.yarnpkg.com (registry.yarnpkg.com)|2606:4700::6810:1823|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27462 (27K) [application/octet-stream]
Saving to: ‘webpacker-4.2.2.tgz’
webpacker-4.2.2.tgz 100%[==============================>] 26.82K --.-KB/s in 0.002s
@gregblake
gregblake / mysql8_connect_specs.md
Last active July 27, 2020 11:46
MySql 8.0 Updgrade -- Failing Connect Specs

The specs are testing Connect::Message.with_context. This method is used in Connect search. When you click on one of the messages in a set of search results, you can view that message, with context of the conversation (messages written in that conversation immediately before and after the message you selected).

It looks like the specs are breaking on MySql 8.0 because the messages are being returned in a different order than what's expected.

For example, on ./spec/models/connect/message_spec.rb:249, it expected messages in this order:

id: 1418
id: 1420
id: 1421
@gregblake
gregblake / room_memberships.gql
Last active June 29, 2020 19:24
GraphQL request to update room memberships
mutation {
updatedRoom: updateConnectRoom(
id: 32246,
memberships: [{ titleId: 60 }, {userId: 31995} ]
) {
id
name
memberships { id titleId userId territoryId }
}
}
@gregblake
gregblake / message_chaining.rb
Created May 27, 2020 11:00
Message Chaining
[22] pry(main)> Connect::Room.find(1976).messages.pluck(:id, :prev_message_id)
Connect::Room Load (2.0ms) SELECT `connect_rooms`.* FROM `connect_rooms` WHERE `connect_rooms`.`id` = 1976 LIMIT 1
(4.7ms) SELECT `connect_messages`.`id`, `connect_messages`.`prev_message_id` FROM `connect_messages` LEFT OUTER JOIN `connect_message_reactions` ON `connect_message_reactions`.`connect_message_id` = `connect_messages`.`id` LEFT OUTER JOIN `connect_message_shared_files` ON `connect_message_shared_files`.`connect_message_id` = `connect_messages`.`id` LEFT OUTER JOIN `connect_message_mentions` ON `connect_message_mentions`.`connect_message_id` = `connect_messages`.`id` LEFT OUTER JOIN `users` ON `users`.`id` = `connect_message_mentions`.`user_id` WHERE `connect_messages`.`to_id` = 1976 AND `connect_messages`.`to_type` = 'Connect::Room'
=> [[53250783, nil],
[53250784, 53250783],
[53250786, 53250784],
[53252325, 53250786],
[53252326, 53252325],
[53252327, 53252326],
[53252328, 53252327],
@gregblake
gregblake / group_membership_params.rb
Created May 26, 2020 18:28
Group Membership Params
# This request will create group memberships for department_id's 1 & 2, as well as territory_id 1.
group_memberships = [
{ territory_id: nil, branch_id: nil, role_id: nil, department_id: 1, title_id: nil },
{ territory_id: 1, branch_id: nil, role_id: nil, department_id: 2, title_id: nil }
]
@gregblake
gregblake / random.rb
Created May 22, 2020 17:28
Random Generator: Rebel Alliance Members
# This determines who gives their standup update first.
["Lucas", "Lucas Feijo", "lucas.feijo"].sample
@gregblake
gregblake / Connect::Message.with_context.txt
Created February 27, 2020 14:47
Connect::Message.with_context documentation
Connect::Message.with_context
returns a message, and a number of messages that preceed and succeed it, in the same conversation
public rooms
behaves like a conversation that the user has access to
when the preceding & succeeding message count are less than the number of messages in the convo
returns the selected msg, along with the correct # of messages, to provide context for the messsage
when the combined preceding & succeeding message counts are greater than the # of msgs in the convo
returns the selected msg, along with every other message in the conversation
when the preceding_message_count is zero
returns 0 preceeding msgs, the selected msg, & the correct number of succeeding messages in the convo
@gregblake
gregblake / elastic.md
Last active February 18, 2020 16:40
ElasticSearch API Endpoint

ElasticSearch API Endpoint

This endpoint will allow clients to search messages within a given conversation.

  1. Request params (room/group): :to_id, :to_type, :query.
  2. Request params (user): :conversation, :query.
  3. If the query parameter is omitted from the request, it should behave exactly like the messages endpoint. Similarly, if the toggle and/or permission are disabled, it'll behave just like the messages endpoint does, without search filtering.
  4. If the necessary parameters are included: return a 200, with a collection of messages that match the query. The response JSON should match the existing format exactly.

Other considerations

@gregblake
gregblake / elastic_search_upgrade.md
Last active February 14, 2020 17:09
ElasticSearch Upgrade Notes

Steps to Upgrading

  1. Upgraded cluster
  2. Upgrade gems from 2.0.
  3. Audit application for breaking changes, and update them accordingly.
  4. Refresh indices (?)

Other Considerations

  • It looks like we can only upgrade to v6, and not v7 yet. See compatibility chart for the elasticsearch-rails gem.
  • Is the messages table being indexed in production now? If so, will this be compatible after the upgrade? Will we need to refresh the index?