chore(*.psql/*.sql): update all *.psql to *.sql files
This commit is contained in:
parent
c9015a7f2b
commit
fc37600b8b
63 changed files with 21 additions and 41 deletions
|
@ -1,13 +0,0 @@
|
|||
CREATE OR REPLACE FUNCTION slugify(input TEXT)
|
||||
RETURNS TEXT AS $$
|
||||
BEGIN
|
||||
RETURN lower(
|
||||
regexp_replace(
|
||||
unaccent(
|
||||
regexp_replace(input, '[^\w\s-]', '', 'g')
|
||||
),
|
||||
'\s+', '-', 'g'
|
||||
)
|
||||
);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
6
queries/functions/slugify.sql
Normal file
6
queries/functions/slugify.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
CREATE OR REPLACE FUNCTION slugify(input TEXT)
|
||||
RETURNS TEXT AS $$
|
||||
BEGIN
|
||||
RETURN lower(regexp_replace(unaccent(regexp_replace(input, '[^\w\s-]', '', 'g')), '\s+', '-', 'g'));
|
||||
END;
|
||||
$$ LANGUAGE plpgsql IMMUTABLE;
|
|
@ -6,21 +6,17 @@ DECLARE
|
|||
last_read DATE;
|
||||
BEGIN
|
||||
SELECT (NOW() AT TIME ZONE 'America/Los_Angeles')::DATE INTO pacific_today;
|
||||
|
||||
SELECT COALESCE(last_read_date::DATE, pacific_today - INTERVAL '1 day') INTO last_read FROM reading_streak LIMIT 1;
|
||||
|
||||
IF last_read < pacific_today - INTERVAL '1 day' THEN
|
||||
UPDATE reading_streak
|
||||
SET days_read = 0, last_read_date = NOW() AT TIME ZONE 'America/Los_Angeles'
|
||||
WHERE id = 1;
|
||||
END IF;
|
||||
|
||||
IF last_read IS DISTINCT FROM pacific_today THEN
|
||||
UPDATE reading_streak
|
||||
SET days_read = days_read + 1, last_read_date = NOW() AT TIME ZONE 'America/Los_Angeles'
|
||||
WHERE id = 1;
|
||||
END IF;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
|
@ -5,7 +5,6 @@ BEGIN
|
|||
SET status = 'aired'
|
||||
WHERE air_date < CURRENT_DATE
|
||||
AND status = 'upcoming';
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
|
@ -6,7 +6,6 @@ BEGIN
|
|||
WHERE show_id = NEW.show
|
||||
AND season_number = NEW.season_number
|
||||
AND episode_number = NEW.episode_number;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
|
@ -2,12 +2,10 @@ BEGIN
|
|||
UPDATE artists
|
||||
SET total_plays = total_plays - 1
|
||||
WHERE name_string = OLD.artist_name;
|
||||
|
||||
UPDATE albums
|
||||
SET total_plays = total_plays - 1
|
||||
WHERE name = OLD.album_name
|
||||
AND artist_name = OLD.artist_name;
|
||||
|
||||
UPDATE genres
|
||||
SET total_plays = total_plays - 1
|
||||
WHERE id = (
|
||||
|
@ -15,6 +13,5 @@ BEGIN
|
|||
FROM artists
|
||||
WHERE name_string = OLD.artist_name
|
||||
);
|
||||
|
||||
RETURN OLD;
|
||||
END;
|
|
@ -4,7 +4,6 @@ BEGIN
|
|||
IF NEW.air_date < CURRENT_DATE AND NEW.status = 'upcoming' THEN
|
||||
NEW.status := 'aired';
|
||||
END IF;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
|
@ -2,12 +2,10 @@ BEGIN
|
|||
UPDATE artists
|
||||
SET total_plays = total_plays + 1
|
||||
WHERE name_string = NEW.artist_name;
|
||||
|
||||
UPDATE albums
|
||||
SET total_plays = total_plays + 1
|
||||
WHERE key = NEW.album_key
|
||||
AND artist_name = NEW.artist_name;
|
||||
|
||||
UPDATE genres
|
||||
SET total_plays = total_plays + 1
|
||||
WHERE id = (
|
||||
|
@ -15,6 +13,5 @@ BEGIN
|
|||
FROM artists
|
||||
WHERE name_string = NEW.artist_name
|
||||
);
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
Loading…
Add table
Add a link
Reference in a new issue