Skip to content

Instantly share code, notes, and snippets.

View gregblake's full-sized avatar
👨‍💻

Greg Blake gregblake

👨‍💻
View GitHub Profile
@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?
@gregblake
gregblake / standup.md
Created February 12, 2020 14:29
Standup Update -- Wednesday 2/12/2020

What did I do yesterday to help the team meet the sprint goal?

  • Completed the story that adds a new composite index to the connect_rooms table. This is in production. No new errors in Sentry.
  • Began working on two new stories:
    1. Add two new feature toggles for Connect search.
    2. Add a new permission for Connect search.
    • Both of these PR's received code review and testing approval. I merged both PR's in the afternoon. Another team reverted a PR shortly after that, so they shipped via emergency deployment. But I followed that deployment into production. No new errors in Sentry.
  • Worked on the story to optimize the connect_room_users query. A PR is open, and the feature is nearly completed.
  • Code review.
  • Chatted with Jenny about upgrading the mobile app from RN v0.59 to v0.60/v0.61.
  • Attended the All Hands meeting.
❯ echo "[RBLS-39]" | sed 's/^\[\(.*\)\]$/\1/'
RBLS-39
❯ echo "[INC-3399993]" | sed 's/^\[\(.*\)\]$/\1/'
INC-3399993
@gregblake
gregblake / TypeError.log
Created January 31, 2020 14:17
Uncaught TypeError: Cannot convert undefined or null to object
Uncaught TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Message.renderReactions (Message.jsx?dd7c:405)
at Message.render (Message.jsx?dd7c:445)
at eval (ReactCompositeComponent.js?cd59:793)
at measureLifeCyclePerf (ReactCompositeComponent.js?cd59:74)
at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js?cd59:792)
at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js?cd59:819)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js?cd59:361)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js?cd59:257)
@gregblake
gregblake / RBLS-2.md
Created January 21, 2020 15:33
Testing notes for RBLS-2

Android

App State Behavior after Tapping Notification
Foreground Same as prod
Background Route to conversation
Not Running Route to conversation

Some/all Android devices don't receive push notifications when the app is in the foreground, so that's why I mentioned "same as prod" for Android apps when the app is in the foreground).

@gregblake
gregblake / active_record_includes.md
Last active December 17, 2019 13:46
Using ActiveRecord's Eager Loading Associations to Optimize a Query

This query optimization can be recreated locally, by running the following and grepping the logs (comparing the master branch to this feature branch).

Prior to this PR, the number of queries issued was dependent upon the number of rooms in the collection (N+1). In production, the collection often contains many rooms. Now, only two queries are issued, no matter how many rooms are in the collection.

From the Rails console:

rooms = Connect::Room.where(private: true, archived: false).first(10);
rooms.each do |room|
  Connect::Message.create(from_id: 618, to: room, body: "u#all");
end
@gregblake
gregblake / truncate_rails_tables.rb
Created December 10, 2019 13:28 — forked from romanblick/truncate_rails_tables.rb
Truncate all tables in rails
ActiveRecord::Base.establish_connection
ActiveRecord::Base.connection.execute("SET FOREIGN_KEY_CHECKS=0;")
ActiveRecord::Base.connection.tables.each do |table|
next if table == 'schema_migrations'
case ActiveRecord::Base.connection.adapter_name.downcase.to_sym
when :mysql2 || :postgresql
ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
when :sqlite
@gregblake
gregblake / standup.md
Last active October 9, 2019 21:22
Standup Update: Thursday 10/9/19

What did I do Wednesday to help the team meet the sprint goal?

  • Finished the “ Image partially grays when loading” story.
  • Picked up the “wrong label & color when removing a bookmark” story from the backlog.
    • This is in production.
  • Picked up the “unable to view a user's contact details” story from the backlog.
    • This one has code review approval, and is in testing.
  • I did some code review.