Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed Jun 4, 2024
2 parents f1c0036 + 0d6acaf commit 3f0f251
Show file tree
Hide file tree
Showing 83 changed files with 1,217 additions and 499 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Once the application has started, navigate to http://localhost:8080 and login wi

If you are running Docker on Windows and the application crashes immediately upon startup, please ensure that `autocrlf` is set to `false` in your Git config, and then re-clone the repository. Additionally, it is recommended that you allocate at least 4GB of RAM to your Docker VM.

If you run into an Elasticsearch bootstrap error, you may need to increase your `max_map_count` on the host as follows:
If you run into an OpenSearch bootstrap error, you may need to increase your `max_map_count` on the host as follows:
```
sudo sysctl -w vm.max_map_count=262144
```
Expand Down
1 change: 1 addition & 0 deletions assets/css/views/_tags.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
position: absolute;
user-select: none;
white-space: nowrap;
z-index: 999;
}

.autocomplete__item {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function listenAutocomplete() {
return;
}

originalTerm = selectedTerm[1];
originalTerm = selectedTerm[1].toLowerCase();
}
else {
originalTerm = `${inputField.value}`.toLowerCase();
Expand Down
4 changes: 2 additions & 2 deletions docker/app/run-test
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export MIX_ENV=test
# Always install mix dependencies
(cd /srv/philomena && mix deps.get)

# Sleep to allow Elasticsearch to finish initializing
# Sleep to allow OpenSearch to finish initializing
# if it's not done doing whatever it does yet
echo -n "Waiting for Elasticsearch"
echo -n "Waiting for OpenSearch"

until wget -qO - opensearch:9200; do
echo -n "."
Expand Down
16 changes: 8 additions & 8 deletions lib/mix/tasks/reindex_all.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Mix.Tasks.ReindexAll do
use Mix.Task

alias Philomena.Elasticsearch
alias PhilomenaQuery.Search

alias Philomena.{
Comments.Comment,
Expand All @@ -27,7 +27,7 @@ defmodule Mix.Tasks.ReindexAll do
{Filters, Filter}
]

@shortdoc "Destroys and recreates all Elasticsearch indices."
@shortdoc "Destroys and recreates all OpenSearch indices."
@requirements ["app.start"]
@impl Mix.Task
def run(args) do
Expand All @@ -38,23 +38,23 @@ defmodule Mix.Tasks.ReindexAll do
@indices
|> Enum.map(fn {context, schema} ->
Task.async(fn ->
Elasticsearch.delete_index!(schema)
Elasticsearch.create_index!(schema)
Search.delete_index!(schema)
Search.create_index!(schema)

Elasticsearch.reindex(preload(schema, ^context.indexing_preloads()), schema)
Search.reindex(preload(schema, ^context.indexing_preloads()), schema)
end)
end)
|> Task.await_many(:infinity)

# Reports are a bit special

Elasticsearch.delete_index!(Report)
Elasticsearch.create_index!(Report)
Search.delete_index!(Report)
Search.create_index!(Report)

Report
|> preload([:user, :admin])
|> Repo.all()
|> Polymorphic.load_polymorphic(reportable: [reportable_id: :reportable_type])
|> Enum.map(&Elasticsearch.index_document(&1, Report))
|> Enum.map(&Search.index_document(&1, Report))
end
end
2 changes: 1 addition & 1 deletion lib/mix/tasks/upload_to_s3.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Mix.Tasks.UploadToS3 do

alias Philomena.Images.Thumbnailer
alias Philomena.Objects
alias Philomena.Batch
alias PhilomenaQuery.Batch
import Ecto.Query

@shortdoc "Dumps existing image files to S3 storage backend"
Expand Down
8 changes: 4 additions & 4 deletions lib/philomena/comments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ defmodule Philomena.Comments do
alias Ecto.Multi
alias Philomena.Repo

alias Philomena.Elasticsearch
alias PhilomenaQuery.Search
alias Philomena.Reports.Report
alias Philomena.UserStatistics
alias Philomena.Comments.Comment
alias Philomena.Comments.ElasticsearchIndex, as: CommentIndex
alias Philomena.Comments.SearchIndex, as: CommentIndex
alias Philomena.IndexWorker
alias Philomena.Images.Image
alias Philomena.Images
Expand Down Expand Up @@ -295,7 +295,7 @@ defmodule Philomena.Comments do
def user_name_reindex(old_name, new_name) do
data = CommentIndex.user_name_update_by_query(old_name, new_name)

Elasticsearch.update_by_query(Comment, data.query, data.set_replacements, data.replacements)
Search.update_by_query(Comment, data.query, data.set_replacements, data.replacements)
end

def reindex_comment(%Comment{} = comment) do
Expand All @@ -318,6 +318,6 @@ defmodule Philomena.Comments do
Comment
|> preload(^indexing_preloads())
|> where([c], field(c, ^column) in ^condition)
|> Elasticsearch.reindex(Comment)
|> Search.reindex(Comment)
end
end
2 changes: 1 addition & 1 deletion lib/philomena/comments/query.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Philomena.Comments.Query do
alias Philomena.Search.Parser
alias PhilomenaQuery.Parse.Parser

defp user_id_transform(_ctx, data) do
case Integer.parse(data) do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Philomena.Comments.ElasticsearchIndex do
@behaviour Philomena.ElasticsearchIndex
defmodule Philomena.Comments.SearchIndex do
@behaviour PhilomenaQuery.SearchIndex

@impl true
def index_name do
Expand Down
Loading

0 comments on commit 3f0f251

Please sign in to comment.