package consumers
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
module CollectionCacheKey
extend ActiveSupport::Concern
def cache_key_for(scope)
relation = scope.respond_to?(:all) ? scope.all : scope
model = relation.klass
class AddUniqueIndexToTags < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
def up
execute <<~SQL
UPDATE tags SET name = LOWER(TRIM(name)) WHERE name IS NOT NULL;
class ExplainAnalyzer
def initialize(relation, watched_tables:)
@relation = relation
@watched_tables = Array(watched_tables).map(&:to_s)
end
CREATE TABLE posts (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
author_id bigint NOT NULL REFERENCES authors (id),
title text NOT NULL,
body text NOT NULL,
published_at timestamptz NOT NULL DEFAULT now()
module RetryableTransaction
module_function
RETRIABLE = [ActiveRecord::Deadlocked, ActiveRecord::LockWaitTimeout].freeze
def run(max_retries: 3, base_delay: 0.05, &block)
package importers
import (
"context"
"encoding/csv"
"io"
class CreateMaintenanceTasks < ActiveRecord::Migration[7.0]
def change
create_table :maintenance_tasks do |t|
t.string :name, null: false
t.string :state, null: false, default: "pending"
t.datetime :started_at
class CreateEmailDeliveries < ActiveRecord::Migration[7.1]
def change
create_table :email_deliveries do |t|
t.string :dedupe_key, null: false
t.string :mailer, null: false
t.string :action, null: false
export interface PageInfo {
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
endCursor: string | null;
}
module ExistenceChecks
extend ActiveSupport::Concern
class_methods do
def has_any?(conditions = {})
relation = conditions.present? ? where(conditions) : all
import DataLoader from "dataloader";
import { Pool } from "pg";
export interface User { id: number; name: string; }
export interface Post { id: number; user_id: number; title: string; }