Skip to content

Instantly share code, notes, and snippets.

View Pomeha's full-sized avatar
💎
Keep calm and code

Vladislav Akimenko Pomeha

💎
Keep calm and code
View GitHub Profile
@Pomeha
Pomeha / paginate.rb
Created April 7, 2020 10:27
Infinite scroll example
# frozen_string_literal: true
class Paginate
def call(
scope,
direction: 'asc',
field: nil,
last_id: nil,
field_value: nil,
limit: nil
@Pomeha
Pomeha / example.sql
Created March 1, 2021 14:20
Limit by record type on table
SELECT * FROM
(
SELECT (CASE WHEN post_id IS NOT NULL THEN ROW_NUMBER() OVER (PARTITION BY (post_id IS NOT NULL)::integer) END) AS r_post,
(CASE WHEN event_id IS NOT NULL THEN ROW_NUMBER() OVER (PARTITION BY (event_id IS NOT NULL)::integer) END) AS r_event,
t.*
FROM feed_items t)
feed_items
WHERE r_post <= VALUE OR r_event <= VALUE;