<%# Fragment caching - caches rendered HTML %>
<% cache @product do %>
<h1><%= @product.name %></h1>
<p><%= @product.description %></p>
<p>Price: $<%= @product.price %></p>
<% end %>
class CreateCustomerRevenueSummaries < ActiveRecord::Migration[7.0]
def change
create_view :customer_revenue_summaries, materialized: true, version: 1
add_index :customer_revenue_summaries,
:customer_id,
-- Create basic index
CREATE INDEX idx_users_email ON users(email);
-- Unique index (enforces uniqueness)
CREATE UNIQUE INDEX idx_users_username ON users(username);
CREATE TABLE subscriptions (
id BIGGENERATED ALWAYS AS IDENTITY PRIMARY KEY,
customer_id BIGINT NOT NULL,
plan_code TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'active',
current_period_end TIMESTAMPTZ NOT NULL,
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["sentinel"]
static values = {
url: String
import { Link } from 'react-router-dom'
import { useQueryClient } from '@tanstack/react-query'
import api from '@/services/api'
import { PostId } from '@/types'
interface PostLinkProps {
import React from 'react'
interface SkeletonProps {
width?: string | number
height?: string | number
className?: string
module KeysetPaginatable
extend ActiveSupport::Concern
class_methods do
def keyset_page(cursor: nil, limit: 20, direction: :desc)
limit = limit.to_i.clamp(1, 100)
Rails.application.config.middleware.insert_before(
Rack::Runtime,
Rack::Timeout,
service_timeout: 15 # 15 seconds
)
package feed
import (
"encoding/base64"
"encoding/json"
"time"
class LeaderboardCache
TOP_KEY = "leaderboard:top".freeze
STATS_KEY = "leaderboard:stats".freeze
def top_players
Rails.cache.fetch(TOP_KEY, expires_in: 5.minutes, race_condition_ttl: 15.seconds) do
from django.db import models
from django.contrib.postgres.indexes import GinIndex
class Post(models.Model):
title = models.CharField(max_length=200, db_index=True)