Skip to content

Commit

Permalink
Simplify created_at to an integer
Browse files Browse the repository at this point in the history
We don’t facet on this so we can save a lot of bytes per record on this
  • Loading branch information
NuckChorris committed Oct 19, 2024
1 parent 897f06a commit 54d2288
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions app/indices/typesense_base_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ class TypesenseBaseIndex < Typesensual::Index
schema do
enable_nested_fields

field 'created_at', type: 'object'
field 'created_at.year', type: 'int32', facet: true, optional: true
field 'created_at.month', type: 'int32', facet: true, optional: true
field 'created_at.day', type: 'int32', facet: true, optional: true
field 'created_at.timestamp', type: 'int64', optional: true
field 'created_at', type: 'int32', optional: true
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/indices/typesense_manga_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def index(ids)
genres: manga.genres.ids,
chapter_count: manga.chapter_count,
volume_count: manga.volume_count,
created_at: format_date(manga.created_at)
created_at: manga.created_at.to_i
}.compact)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/indices/typesense_users_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def index(ids)
past_names: user.past_names || [],
slug: user.slug,
followers_count: user.followers_count,
created_at: format_date(user.created_at)
created_at: user.created_at.to_i
}.compact)
end
end
Expand Down

0 comments on commit 54d2288

Please sign in to comment.