Skip to content

Instantly share code, notes, and snippets.

@CodingGeniusAD
CodingGeniusAD / gist:c92afa18646c0da331178b48fae36e92
Created January 13, 2026 13:25
structure.sql (only for visits)
-- ============================================================
-- VISITS (High-volume, tenant-aware domain)
-- ============================================================
CREATE TABLE public.visits (
id BIGSERIAL PRIMARY KEY,
hotel_id BIGINT NOT NULL,
user_id BIGINT,
arrival_date DATE,
departure_date DATE,
@CodingGeniusAD
CodingGeniusAD / initialize_shop_service.rb
Created July 31, 2024 19:33
I have my own Shopify App. When I built it, Shopify theme extention was not launched and when merchant installs our app, we were need to add our custom code in merchant store theme. Initially, I tried to do it using Nokogiri gem, but its success ratio to add our app code in correct place was around 70 to 80 percent. because themes are in liquid …
class InitializeShopService
require 'yaml'
def self.testing(shop_info = {shop_session: nil, shop: nil})
raise StandardError, "Invalid Shop" if shop_info[:shop_session].try(:[], :token).blank? && shop_info[:shop].blank?
# for add/update files in shopify
new(shop_info).add_store_front_functionality
end
def self.set_store_front(shop_info = {shop_session: nil, shop: nil, theme_id: nil})
@CodingGeniusAD
CodingGeniusAD / staff_console_query.rb
Created July 31, 2024 19:31
In this file, I am handling the sorting or records.
class StaffConsoleQuery
def initialize(relation:, user: nil)
@relation = relation
@user = user
end
def sort(order = :unresolved_requests)
@relation = REQUIRE_GUESTS.include?(order) ? relation.joins(:guest) : relation
join_associations(order).order(SORTING[order] ? Arel.sql(SORTING[order]) : SORTING[order])
end
class MerchantWebhooks::TriggerMerchantWebhook
def initialize(webhook, klass, id)
@webhook = webhook
@klass = klass
@record = klass.constantize.find(id)
end
def self.call(webhook, klass, id)
new(webhook, klass, id).perform
end