-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhashtags.js
32 lines (28 loc) · 866 Bytes
/
hashtags.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use strict";
const moment = require("moment");
const isInDateRange = (timestamps, limit = 0, intervalLength, intervalUnit) => {
const array = Object.values(timestamps);
return (
array.length >= limit &&
array
.slice(-limit)
.every(timestamp =>
moment(timestamp).isAfter(
moment().subtract(intervalLength, intervalUnit)
)
)
);
};
module.exports = {
military: ({ dbFlags }, snap) => dbFlags === 1 && "military",
busyday: (state, snap) =>
Boolean(snap.val()) &&
isInDateRange(snap.val().timestamps, 3, 24, "hours") &&
"busyday",
frequentflyer: (state, snap) =>
Boolean(snap.val()) &&
isInDateRange(snap.val().timestamps, 30, 90, "days") &&
"frequentflyer",
phiden: ({ hex }, snap) => hex === "A0E429" && "phiden",
firstspot: (state, snap) => !snap.val() && "firstspot"
};