Skip to content

Commit

Permalink
more logging and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rmnoon committed Jun 21, 2022
1 parent 125724f commit 0120f8c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 42 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"@slack/web-api": "^6.7.2",
"@upstash/redis": "^1.1.0",
"node-fetch": "^2.6.7",
"postgres": "^3.2.4",
"vercel": "^24.0.0"
},
"devDependencies": {
Expand Down
25 changes: 3 additions & 22 deletions src/api/_acks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sql, slack, redis } from './_constants';
import { slack, redis } from './_constants';
import { log } from './_Slack';
import { Block } from './_SlackJson';
import { map } from './_util';
Expand All @@ -7,31 +7,12 @@ const DEFAULT_CONCURRENCY = 3;

const REDIS_ACK_KEY = 'acks';

const REMINDER_FREQUENCY_MIN = 1;
const REMINDER_FREQUENCY_MIN = 24 * 60;

const REMINDER_FREQUENCY_MS = REMINDER_FREQUENCY_MIN * 60 * 1000;

const DEBUG_CHECK_ALL = false;

export async function checkForRemindersSql() {
const now = new Date().getTime();
const test = await sql`
insert into ackbot
(checktime, channel, ts)
values
(${now}, ${'lolchannel'}, ${'lolts'})
returning name, age
`;

console.log('test: ', { test });
return test;
// get k items with a check time earlier than a day ago

// check each of them

// for any not done yet enqueue them with their most recent check time
}

export async function checkForReminders() {
const now = new Date().getTime();
const upperBound = DEBUG_CHECK_ALL ? '+inf' : now - REMINDER_FREQUENCY_MS;
Expand Down Expand Up @@ -66,7 +47,7 @@ export async function checkForReminders() {
if (incomplete.length > 0) {
await saveReminders(incomplete);
}

console.log('checkForReminders done: ', { vals, complete, incomplete, now, upperBound });
return { vals, complete, incomplete, now, upperBound };
}

Expand Down
9 changes: 0 additions & 9 deletions src/api/_constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Redis } from '@upstash/redis/with-fetch';
import { WebClient } from '@slack/web-api';
import postgres from 'postgres';

export const SLACK_SIGNING_SECRET = process.env.SLACK_SIGNING_SECRET;

Expand All @@ -10,12 +9,4 @@ export const redis = new Redis({
token: process.env.UPSTASH_REDIS_REST_TOKEN,
});

export const sql = postgres({
host: process.env.PGHOST,
database: process.env.PGDATABASE,
username: process.env.PGUSER,
password: process.env.PGPASSWORD,
ssl: 'require',
});

export const slack = new WebClient(process.env.SLACK_BOT_TOKEN);
10 changes: 0 additions & 10 deletions src/api/hello.ts

This file was deleted.

1 comment on commit 0120f8c

@vercel
Copy link

@vercel vercel bot commented on 0120f8c Jun 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ackbot – ./

ackbot-rmnoon.vercel.app
ackbot.vercel.app
ackbot-git-main-rmnoon.vercel.app

Please sign in to comment.