mirror of
https://github.com/mikedilger/chorus.git
synced 2026-08-01 07:21:39 +00:00
Use ci index to return scraper results in reverse chronological order, and limit them
This commit is contained in:
parent
9e7dd214f4
commit
39736cc0b9
@ -99,7 +99,6 @@ impl Store {
|
||||
txn.commit()?;
|
||||
|
||||
let event_map_file = format!("{}/event.map", data_directory);
|
||||
|
||||
let events = EventStore::new(event_map_file)?;
|
||||
|
||||
let store = Store {
|
||||
@ -378,13 +377,18 @@ impl Store {
|
||||
// This is INEFFICIENT as it scans through EVERY EVENT
|
||||
// but the filter is a scraper and we don't have a lot of support
|
||||
// for scrapers.
|
||||
let mut count = 0;
|
||||
let txn = self.env.read_txn()?;
|
||||
let iter = self.ids.iter(&txn)?;
|
||||
let iter = self.ci.iter(&txn)?;
|
||||
for result in iter {
|
||||
let (_key, offset) = result?;
|
||||
if let Some(event) = self.events.get_event_by_offset(offset)? {
|
||||
if filter.event_matches(&event)? {
|
||||
output.push(event);
|
||||
count += 1;
|
||||
if count >= filter.limit() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user