This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
batch = AngryBatch.new label: 'BulkWithdraw' | |
# check inherits from ActiveJob::Base | |
batch.on_complete Finance::WithdrawBulkCompleteJob, bulk_withdraw | |
zerod_fees do |fee| | |
# check inherits from ActiveJob::Base | |
# check job includes AngryJob::Batchable | |
batch.enqueue Taxation::MaintenanceTaxAutoAdjustmentJob, bulk_withdraw, fee: fee, amount: 0 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'net/http' | |
require 'json' | |
module OpenAI | |
extend self | |
API_KEY = ENV.fetch('openai_api_key') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as glob from 'glob'; | |
import difference from 'lodash/difference'; | |
import startCase from 'lodash/startCase'; | |
import union from 'lodash/union'; | |
import uniq from 'lodash/uniq'; | |
import { CodeFileLoader } from '@graphql-tools/code-file-loader'; | |
import { DocumentNode, DefinitionNode, OperationDefinitionNode } from 'graphql'; | |
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader'; | |
import { loadDocuments } from '@graphql-tools/load'; | |
import { visit } from 'graphql/language/visitor'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module ErrorReporting | |
extend self | |
def assign_user(user) | |
return unless Rails.env.production? | |
Sentry.set_user( | |
id: user.id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AngrySupport::BelongsToPolymorphic | |
def belongs_to_polymorphic(name, allowed_classes:, **options) | |
belongs_to name, polymorphic: true, **options | |
validates "#{name}_type", inclusion: { in: allowed_classes.map(&:name), allow_nil: !!options[:optional] } | |
define_singleton_method(:"#{name}_types") { allowed_classes } | |
define_singleton_method(:"with_#{name}") do |type| | |
type = case type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationComponent < ViewComponent::Base | |
private | |
def fetch_with_fallback(hash, key, fallback) | |
hash.fetch(key) do | |
ErrorReporting.capture_exception(%(key not found: "#{key}")) | |
fallback | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION comments_count_update() | |
RETURNS TRIGGER AS $$ | |
BEGIN | |
-- Increase count on insert | |
IF (TG_OP = 'INSERT') THEN | |
UPDATE posts SET comments_count = comments_count + 1 | |
WHERE posts.id = NEW.post_id; | |
RETURN NEW; | |
-- Decrease count on delete | |
ELSIF (TG_OP = 'DELETE') THEN |
NewerOlder