Skip to content

Commit a43303f

Browse files
chore: disable search indexing
1 parent 0eb73d6 commit a43303f

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

src/search.ts

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
const algoliasearch = require('algoliasearch');
2-
import * as db from './database';
1+
// const algoliasearch = require('algoliasearch');
2+
// import * as db from './database';
33

4-
if (process.env.ALGOLIA_APPLICATION_ID && process.env.ALGOLIA_ADMIN_KEY) {
5-
const client = algoliasearch(process.env.ALGOLIA_APPLICATION_ID, process.env.ALGOLIA_ADMIN_KEY);
4+
// if (process.env.ALGOLIA_APPLICATION_ID && process.env.ALGOLIA_ADMIN_KEY) {
5+
// const client = algoliasearch(process.env.ALGOLIA_APPLICATION_ID, process.env.ALGOLIA_ADMIN_KEY);
66

7-
const index = client.initIndex('messages');
8-
index.setSettings({"attributeForDistinct":"subjectID"});
7+
// const index = client.initIndex('messages');
8+
// index.setSettings({"attributeForDistinct":"subjectID"});
99

10-
// initially, we load in pages of 60 records, once per minute until we have looked at the most recent 100 records
11-
// we then check every hour to see if there are any new records, loading in pages of 5 until we get to the most
12-
// recent record we've seen.
13-
let perPage = 60;
14-
let latestMessage = '0000-00-00';
15-
let currentRoundLatestMessage = '0000-00-00';
16-
let roundComplete = false;
17-
function processPage(start: number) {
18-
if (roundComplete || start > 100) {
19-
latestMessage = currentRoundLatestMessage;
20-
roundComplete = false;
21-
setTimeout(() => {
22-
perPage = 5;
23-
processPage(0);
24-
}, 60 * 60_000);
25-
return;
26-
}
27-
db.getAllMessagesForSearch(start, perPage).then(messages => {
28-
messages.forEach(message => {
29-
const messageDate = message.date.toISOString().split('T')[0];
30-
// keep track of the newest message we've seen this round
31-
if (messageDate > currentRoundLatestMessage) {
32-
currentRoundLatestMessage = messageDate;
33-
}
34-
// if the message is older than the most recent message, end the round
35-
if (messageDate < latestMessage) {
36-
roundComplete = true;
37-
}
38-
});
39-
index.saveObjects(messages, (err: any) => {
40-
if (err) {
41-
throw err;
42-
}
43-
setTimeout(() => {
44-
processPage(start + perPage);
45-
}, 5 * 60_000);
46-
});
47-
});
48-
}
49-
processPage(0);
50-
}
10+
// // initially, we load in pages of 60 records, once per minute until we have looked at the most recent 100 records
11+
// // we then check every 24 hours to see if there are any new records, loading in pages of 5 until we get to the most
12+
// // recent record we've seen.
13+
// let perPage = 60;
14+
// let latestMessage = '0000-00-00';
15+
// let currentRoundLatestMessage = '0000-00-00';
16+
// let roundComplete = false;
17+
// function processPage(start: number) {
18+
// if (roundComplete || start > 100 || (new Date()).toISOString().split('T')[0] < '') {
19+
// latestMessage = currentRoundLatestMessage;
20+
// roundComplete = false;
21+
// setTimeout(() => {
22+
// perPage = 5;
23+
// processPage(0);
24+
// }, 24 * 60 * 60_000);
25+
// return;
26+
// }
27+
// db.getAllMessagesForSearch(start, perPage).then(messages => {
28+
// messages.forEach(message => {
29+
// const messageDate = message.date.toISOString().split('T')[0];
30+
// // keep track of the newest message we've seen this round
31+
// if (messageDate > currentRoundLatestMessage) {
32+
// currentRoundLatestMessage = messageDate;
33+
// }
34+
// // if the message is older than the most recent message, end the round
35+
// if (messageDate < latestMessage) {
36+
// roundComplete = true;
37+
// }
38+
// });
39+
// index.saveObjects(messages, (err: any) => {
40+
// if (err) {
41+
// throw err;
42+
// }
43+
// setTimeout(() => {
44+
// processPage(start + perPage);
45+
// }, 20 * 60_000);
46+
// });
47+
// });
48+
// }
49+
// processPage(0);
50+
// }

0 commit comments

Comments
 (0)