Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
fix migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
andremedeiros committed May 21, 2022
1 parent 90f232a commit 09d5457
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
8 changes: 4 additions & 4 deletions internal/worker/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
)

const (
backoff = 5 // How long we wait in between checking for notifications, in seconds
pollDuration = 5 * time.Millisecond
rate = 0.1
checkInterval = 5 * time.Second // How long we wait in between checking for notifications, in seconds
pollDuration = 5 * time.Millisecond
rate = 0.1

postReplyNotificationTitleFormat = "%s to %s"
commentReplyNotificationTitleFormat = "%s in %s"
Expand Down Expand Up @@ -239,7 +239,7 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
// Only update delay on accounts we can actually check, otherwise it skews
// the numbers too much.
if !newAccount {
latency := now.Sub(previousNextCheck) - backoff*time.Second
latency := now.Sub(previousNextCheck) - checkInterval
_ = nc.statsd.Histogram("apollo.queue.delay", float64(latency.Milliseconds()), []string{}, rate)
}

Expand Down
16 changes: 5 additions & 11 deletions migrations/000001_create_accounts.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@

CREATE TABLE accounts (
id SERIAL PRIMARY KEY,
reddit_account_id character varying(32) DEFAULT ''::character varying,
username character varying(20) DEFAULT ''::character varying UNIQUE,
access_token character varying(64) DEFAULT ''::character varying,
refresh_token character varying(64) DEFAULT ''::character varying,
expires_at integer DEFAULT 0,
token_expires_at timestamp without time zone,
last_message_id character varying(32) DEFAULT ''::character varying,
device_count integer DEFAULT 0,
last_checked_at double precision DEFAULT '0'::double precision,
last_enqueued_at double precision DEFAULT '0'::double precision,
account_id character varying(32) DEFAULT ''::character varying,
last_unstuck_at double precision DEFAULT '0'::double precision
next_notification_check_at timestamp without time zone,
next_stuck_notification_check_at timestamp without time zone,
check_count integer DEFAULT 0
);

-- Indices -------------------------------------------------------

CREATE INDEX accounts_last_checked_at_idx ON accounts(last_checked_at float8_ops);

2 changes: 1 addition & 1 deletion migrations/000004_create_subreddits.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ CREATE TABLE subreddits (
id SERIAL PRIMARY KEY,
subreddit_id character varying(32) DEFAULT ''::character varying UNIQUE,
name character varying(32) DEFAULT ''::character varying,
last_checked_at double precision DEFAULT '0'::double precision
next_check_at timestamp without time zone
);

2 changes: 1 addition & 1 deletion migrations/000005_create_users.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ CREATE TABLE users (
id SERIAL PRIMARY KEY,
user_id character varying(32) DEFAULT ''::character varying UNIQUE,
name character varying(32) DEFAULT ''::character varying,
last_checked_at double precision DEFAULT '0'::double precision
next_check_at timestamp without time zone
);

6 changes: 3 additions & 3 deletions migrations/000006_create_watchers.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

CREATE TABLE watchers (
id SERIAL PRIMARY KEY,
created_at timestamp without time zone,
last_notified_at timestamp without time zone,
device_id integer REFERENCES devices(id) ON DELETE CASCADE,
account_id integer REFERENCES accounts(id) ON DELETE CASCADE,
watchee_id integer,
upvotes integer DEFAULT 0,
keyword character varying(32) DEFAULT ''::character varying,
flair character varying(32) DEFAULT ''::character varying,
domain character varying(32) DEFAULT ''::character varying,
account_id integer REFERENCES accounts(id) ON DELETE CASCADE,
created_at double precision DEFAULT '0'::double precision,
hits integer DEFAULT 0,
type integer DEFAULT 0,
last_notified_at double precision DEFAULT '0'::double precision,
label character varying(64) DEFAULT ''::character varying,
author character varying(32) DEFAULT ''::character varying,
subreddit character varying(32) DEFAULT ''::character varying
Expand Down

0 comments on commit 09d5457

Please sign in to comment.