Skip to content

Commit

Permalink
refactor: rename table to representatives_uptime_rollup_hour
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakia committed Apr 23, 2024
1 parent 40eb758 commit eba4b32
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/routes/accounts/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ router.get('/:address', async (req, res) => {
.orderBy('timestamp', 'desc')
.limit(1)

const uptime = await db('representatives_uptime_rollup_2hour')
const uptime = await db('representatives_uptime_rollup_hour')
.where({ account: address })
.orderBy('interval', 'asc')

Expand Down
2 changes: 1 addition & 1 deletion api/routes/representatives/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const loadRepresentatives = async () => {
accounts
)

const uptime = db('representatives_uptime_rollup_2hour')
const uptime = db('representatives_uptime_rollup_hour')
.whereIn('account', accounts)
.orderBy('interval', 'asc')

Expand Down
4 changes: 2 additions & 2 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ CREATE TABLE `representatives_uptime_summary` (
-- Table structure for table `representatives_uptime`
--

DROP TABLE IF EXISTS `representatives_uptime_rollup_2hour`;
DROP TABLE IF EXISTS `representatives_uptime_rollup_hour`;

CREATE TABLE `representatives_uptime_rollup_2hour` (
CREATE TABLE `representatives_uptime_rollup_hour` (
`account` char(65) NOT NULL,
`online` tinyint(1) NOT NULL,

Expand Down
4 changes: 2 additions & 2 deletions scripts/import-uptime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ const importUptime = async () => {

if (inserts.length) {
logger(`saving ${inserts.length} rollups for ${account}`)
await db('representatives_uptime_rollup_2hour')
await db('representatives_uptime_rollup_hour')
.insert(inserts)
.onConflict()
.merge()
}
}

// remove rows for representatives without uptime in the last 14 days
const res = await db('representatives_uptime_rollup_2hour')
const res = await db('representatives_uptime_rollup_hour')
.whereNotIn('account', Object.keys(grouped))
.delete()

Expand Down

0 comments on commit eba4b32

Please sign in to comment.