Welcome to another edition of This Week in #dev, a series of posts where we bring some of the most interesting Slack conversations to the public. Today we’re talking about: GitHub’s shared numbering sequence for Issues and Pull Requests, filtering records in Postgres and database consitency.
Louis Antonopoulos discovered that GitHub Issues and Pull Requests share the same numbering sequence, meaning that the next issue created after a Pull Request is the number after the Pull Request number. He was surprised to find out that this was the case, as he had previously assumed that the UI was doing some kind of text analysis magic.
Matheus Richard suggests it is possible that GitHub uses the same underlying model
for both Issues and Pull Requests, which is why they share the same ID sequence. They also
discussed how GitLab treats issues and PRs differently using different syntax
for reference (
#123 for issues and
!123 for Merge Requests).
Fernando Marques learned about the Postgres’ ANY() method, which can be used in Active Record to filter/scope a search by one of the contents of an array column. Here’s one example of how to use it:
Item.create(tags: ["modern", "leather", "jacket"], ...) Item.where(":tags = ANY(tags)", tags: "modern") # also replaceable with `find_by` # => # [#<Item:0x00000001191df258 # id: 1, # tags: ["modern", "leather", "jacket"], # ...> # ]
Matheus Richard shares two gems to help with database management: database_consistency which finds inconsistencies between AR models and DB tables, and lol_dba which focuses on indexes and can generate a migration to fix any problems.
Neil Carvalho includes pghero on the list. It gives you a nicer view of the statistics collected by pgstatstatement, and suggests missing indexes based on your slower queries, he says. rails-pg-extras is another similar gem, Summer ☀️ adds.