Deduplicate history items (#3279)
This commit is contained in:
parent
6d800da4d4
commit
e3c2bf08e6
2 changed files with 5 additions and 9 deletions
|
|
@ -83,14 +83,7 @@ export class History extends Component {
|
|||
}
|
||||
|
||||
index.search(query, filters).then(content => {
|
||||
// add new items to the bottom
|
||||
const allItems = items;
|
||||
const itemsIds = items.map(i => i.objectID);
|
||||
content.hits.forEach(item => {
|
||||
if (!itemsIds.includes(item.objectID)) {
|
||||
allItems.push(item);
|
||||
}
|
||||
});
|
||||
const allItems = [...items, ...content.hits];
|
||||
|
||||
this.setState({
|
||||
query,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class PageView < ApplicationRecord
|
|||
belongs_to :article
|
||||
|
||||
algoliasearch index_name: "UserHistory", per_environment: true, if: :belongs_to_pro_user? do
|
||||
attributes :referrer, :time_tracked_in_seconds, :user_agent, :article_tags
|
||||
attributes :referrer, :user_agent, :article_tags
|
||||
|
||||
attribute(:article_title) { article.title }
|
||||
attribute(:article_path) { article.path }
|
||||
|
|
@ -38,6 +38,9 @@ class PageView < ApplicationRecord
|
|||
|
||||
attributesForFaceting ["filterOnly(viewable_by)"]
|
||||
|
||||
attributeForDistinct :article_path
|
||||
distinct true
|
||||
|
||||
customRanking ["desc(visited_at_timestamp)"]
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue