Skip to content

Commit

Permalink
improve bad queries (#92)
Browse files Browse the repository at this point in the history
* improve doc insert perf

* remove bad query

* time
  • Loading branch information
vswamidass-sfdc authored Oct 24, 2024
1 parent 63e8e94 commit 4d552ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,11 @@
AI Generated Answers From <b>Your</b> Documentation
</div>
<div class="text-left">
<% cache "footer", expires_in: 60.seconds do %>
<% cache "footer", expires_in: 1.hours do %>
<span class="text-xs text-stone-300">LAST 7 DAYS</span>
<div class="text-sky-300 text-sm ">
<%= Question.all.where("created_at >= ?", 7.days.ago).count %> <span class="font-light text-stone-400"> questions</span>
</div>
<div class="text-sky-300 text-sm ">
<%= Question.all.where("created_at >= ?", 7.days.ago).map(&:get_upvotes).sum(&:size) %> <span class="font-light text-stone-400"> helpful answers</span>
</div>
<div class="text-sky-300 text-sm ">
<%= Document.all.where("updated_at >= ?", 7.days.ago).count %> <span class="font-light text-stone-400"> updated documents</span>
</div>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20241024192237_add_index_to_document.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexToDocument < ActiveRecord::Migration[7.1]
def change
add_index :documents, :check_hash
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4d552ae

Please sign in to comment.