refactor into generic HistoryService/RatioBasedReducer and HRavenHistoryService