class AddSlugToPosts < ActiveRecord::Migration[7.1]
def change
add_column :posts, :slug, :string, null: false
add_index :posts, :slug, unique: true
end
end
namespace :cleanup do
desc "Enqueue a job to purge expired sessions"
task expired_sessions: :environment do
job = ExpiredSessionCleanupJob.perform_later
Rails.logger.info("[cleanup:expired_sessions] enqueued job #{job.job_id}")
end
require "securerandom"
class RedisMutex
class LockError < StandardError; end
UNLOCK_SCRIPT = <<~LUA.freeze
class ExportWriter
def initialize(export)
@export = export
end
def append(rows)
@Entity
@Table(name = "idempotency_records",
uniqueConstraints = @UniqueConstraint(columnNames = "idempotency_key"))
public class IdempotencyRecord {
public enum Status { IN_PROGRESS, COMPLETED }
<?php
namespace App\Jobs;
use App\Models\Invoice;
use App\Services\StripeGateway;
CREATE TABLE events (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
source text NOT NULL,
external_id text NOT NULL,
payload jsonb NOT NULL,
occurred_at timestamptz NOT NULL,
import hmac
import hashlib
import time
from fastapi import Request, HTTPException, status
class DebouncedReindexJob
include Sidekiq::Job
sidekiq_options queue: :indexing, retry: 5
DEBOUNCE_DELAY = 5 # seconds
const RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504]);
export function isRetryable(error: unknown, response?: Response): boolean {
if (response) {
return RETRYABLE_STATUS.has(response.status);
}
class InventoryLevel < ApplicationRecord
belongs_to :warehouse
UPSERT_COLUMNS = %w[warehouse_id sku on_hand reserved updated_at].freeze
def self.upsert_counts(rows)
require "csv"
class ProductImporter
BATCH_SIZE = 500
attr_reader :errors, :inserted