mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-18 07:27:56 +00:00
8670403a67
* Add upload timeout to PictrsConfig * Bad space 🤔 * Update PictrsConfig upload timeout to include units. * Add local_subscribers field to CommunityAggregates struct and schema * sql format * local_subscribers test * fix local_subscribers test * Revert "fix local_subscribers test" This reverts commit4bbac5ce4a
. * Revert "local_subscribers test" This reverts commit735107e1f7
. * Create trigger for local_subscribers * Rename variable * re-trigger ci * re-trigger ci * Add local_subscribers count to follow.spec.ts * Rename local_subscribers to subscribers_local * Add subscribers_local to community_aggregates * added subscribers_local to the aggregate tests * Check if person exists on community_follower trigger * Delete community follows before deleting person * Update lemmy-js-client in api_tests * Refactor local_subscriber migration * fix format * Move migration files date to now * Fix test to wait for aggregates to federate * re-trigger ci --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
42 lines
1.2 KiB
PL/PgSQL
42 lines
1.2 KiB
PL/PgSQL
ALTER TABLE community_aggregates
|
|
DROP COLUMN subscribers_local;
|
|
|
|
-- old function from migrations/2023-10-02-145002_community_followers_count_federated/up.sql
|
|
-- The subscriber count should only be updated for local communities. For remote
|
|
-- communities it is read over federation from the origin instance.
|
|
CREATE OR REPLACE FUNCTION community_aggregates_subscriber_count ()
|
|
RETURNS TRIGGER
|
|
LANGUAGE plpgsql
|
|
AS $$
|
|
BEGIN
|
|
IF (TG_OP = 'INSERT') THEN
|
|
UPDATE
|
|
community_aggregates
|
|
SET
|
|
subscribers = subscribers + 1
|
|
FROM
|
|
community
|
|
WHERE
|
|
community.id = community_id
|
|
AND community.local
|
|
AND community_id = NEW.community_id;
|
|
ELSIF (TG_OP = 'DELETE') THEN
|
|
UPDATE
|
|
community_aggregates
|
|
SET
|
|
subscribers = subscribers - 1
|
|
FROM
|
|
community
|
|
WHERE
|
|
community.id = community_id
|
|
AND community.local
|
|
AND community_id = OLD.community_id;
|
|
END IF;
|
|
RETURN NULL;
|
|
END
|
|
$$;
|
|
|
|
DROP TRIGGER IF EXISTS delete_follow_before_person ON person;
|
|
|
|
DROP FUNCTION IF EXISTS delete_follow_before_person;
|
|
|