mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-24 20:57:43 +00:00
fix migrations
This commit is contained in:
parent
90f232a06d
commit
09d5457436
5 changed files with 14 additions and 20 deletions
|
@ -22,9 +22,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
backoff = 5 // How long we wait in between checking for notifications, in seconds
|
checkInterval = 5 * time.Second // How long we wait in between checking for notifications, in seconds
|
||||||
pollDuration = 5 * time.Millisecond
|
pollDuration = 5 * time.Millisecond
|
||||||
rate = 0.1
|
rate = 0.1
|
||||||
|
|
||||||
postReplyNotificationTitleFormat = "%s to %s"
|
postReplyNotificationTitleFormat = "%s to %s"
|
||||||
commentReplyNotificationTitleFormat = "%s in %s"
|
commentReplyNotificationTitleFormat = "%s in %s"
|
||||||
|
@ -239,7 +239,7 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
|
||||||
// Only update delay on accounts we can actually check, otherwise it skews
|
// Only update delay on accounts we can actually check, otherwise it skews
|
||||||
// the numbers too much.
|
// the numbers too much.
|
||||||
if !newAccount {
|
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)
|
_ = nc.statsd.Histogram("apollo.queue.delay", float64(latency.Milliseconds()), []string{}, rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,19 +2,13 @@
|
||||||
|
|
||||||
CREATE TABLE accounts (
|
CREATE TABLE accounts (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
|
reddit_account_id character varying(32) DEFAULT ''::character varying,
|
||||||
username character varying(20) DEFAULT ''::character varying UNIQUE,
|
username character varying(20) DEFAULT ''::character varying UNIQUE,
|
||||||
access_token character varying(64) DEFAULT ''::character varying,
|
access_token character varying(64) DEFAULT ''::character varying,
|
||||||
refresh_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,
|
last_message_id character varying(32) DEFAULT ''::character varying,
|
||||||
device_count integer DEFAULT 0,
|
next_notification_check_at timestamp without time zone,
|
||||||
last_checked_at double precision DEFAULT '0'::double precision,
|
next_stuck_notification_check_at timestamp without time zone,
|
||||||
last_enqueued_at double precision DEFAULT '0'::double precision,
|
check_count integer DEFAULT 0
|
||||||
account_id character varying(32) DEFAULT ''::character varying,
|
|
||||||
last_unstuck_at double precision DEFAULT '0'::double precision
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Indices -------------------------------------------------------
|
|
||||||
|
|
||||||
CREATE INDEX accounts_last_checked_at_idx ON accounts(last_checked_at float8_ops);
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,6 @@ CREATE TABLE subreddits (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
subreddit_id character varying(32) DEFAULT ''::character varying UNIQUE,
|
subreddit_id character varying(32) DEFAULT ''::character varying UNIQUE,
|
||||||
name character varying(32) DEFAULT ''::character varying,
|
name character varying(32) DEFAULT ''::character varying,
|
||||||
last_checked_at double precision DEFAULT '0'::double precision
|
next_check_at timestamp without time zone
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,6 @@ CREATE TABLE users (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
user_id character varying(32) DEFAULT ''::character varying UNIQUE,
|
user_id character varying(32) DEFAULT ''::character varying UNIQUE,
|
||||||
name character varying(32) DEFAULT ''::character varying,
|
name character varying(32) DEFAULT ''::character varying,
|
||||||
last_checked_at double precision DEFAULT '0'::double precision
|
next_check_at timestamp without time zone
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
|
|
||||||
CREATE TABLE watchers (
|
CREATE TABLE watchers (
|
||||||
id SERIAL PRIMARY KEY,
|
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,
|
device_id integer REFERENCES devices(id) ON DELETE CASCADE,
|
||||||
|
account_id integer REFERENCES accounts(id) ON DELETE CASCADE,
|
||||||
watchee_id integer,
|
watchee_id integer,
|
||||||
upvotes integer DEFAULT 0,
|
upvotes integer DEFAULT 0,
|
||||||
keyword character varying(32) DEFAULT ''::character varying,
|
keyword character varying(32) DEFAULT ''::character varying,
|
||||||
flair character varying(32) DEFAULT ''::character varying,
|
flair character varying(32) DEFAULT ''::character varying,
|
||||||
domain 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,
|
hits integer DEFAULT 0,
|
||||||
type integer DEFAULT 0,
|
type integer DEFAULT 0,
|
||||||
last_notified_at double precision DEFAULT '0'::double precision,
|
|
||||||
label character varying(64) DEFAULT ''::character varying,
|
label character varying(64) DEFAULT ''::character varying,
|
||||||
author character varying(32) DEFAULT ''::character varying,
|
author character varying(32) DEFAULT ''::character varying,
|
||||||
subreddit character varying(32) DEFAULT ''::character varying
|
subreddit character varying(32) DEFAULT ''::character varying
|
||||||
|
|
Loading…
Reference in a new issue