Skip to content

Commit

Permalink
after Simon edit
Browse files Browse the repository at this point in the history
  • Loading branch information
the-last-pastafarian committed Mar 21, 2024
1 parent 93cf53b commit 8976ddd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
5 changes: 3 additions & 2 deletions server/lib/field_hub/couch_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ defmodule FieldHub.CouchService do
)
|> Map.get(:body)
|> Jason.decode!()
|> IO.inspect()

last_sequence = Map.get(changes, "last_seq")

Expand Down Expand Up @@ -390,8 +391,8 @@ defmodule FieldHub.CouchService do
iex> get_last_change_date("development")
"2024-02-29 (edited by André Leroi-Gourhan)"
"""
def get_last_change_date(project_identifier) do
case Map.get(get_last_change_info(project_identifier), "id") do
def get_last_change_date(changes_data, project_identifier) do
case Map.get(changes_data, "id") do
nil ->
:no_changes_found

Expand Down
8 changes: 8 additions & 0 deletions server/lib/field_hub/project.ex
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ defmodule FieldHub.Project do
db_statistics ->
file_statistics = evaluate_file_store(project_identifier)

changes = CouchService.get_last_change_info(project_identifier)

db_statistics =
db_statistics
|> Map.put(:last_update_seq, String.slice(Map.get(changes, "seq"), 0..27) <> "[...]")
|> Map.put(:last_update_id, Map.get(changes, "id"))
|> Map.put(:last_update_date, CouchService.get_last_change_date(changes, project_identifier))

%{
name: project_identifier,
database: db_statistics,
Expand Down
9 changes: 1 addition & 8 deletions server/lib/field_hub_web/live/project_show_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ defmodule FieldHubWeb.ProjectShowLive do
|> assign(:confirm_project_name, "")
|> assign(:delete_files, false)
|> assign(:hide_cache_cleared_message, true)
|> assign(
:last_update_seq,
String.slice(Map.get(CouchService.get_last_change_info(project), "seq"), 0..27) <>
"[...]"
)
|> assign(:last_update_id, Map.get(CouchService.get_last_change_info(project), "id"))
|> assign(:last_update_date, CouchService.get_last_change_date(project))
|> read_project_doc()
}

Expand All @@ -68,7 +61,7 @@ defmodule FieldHubWeb.ProjectShowLive do
) do
stats = Project.evaluate_project(project)

Process.send_after(self(), :update_overview, 10000)
# Process.send_after(self(), :update_overview, 10000)

{
:noreply,
Expand Down
11 changes: 7 additions & 4 deletions server/lib/field_hub_web/live/project_show_live.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@
<% %{
database: %{
doc_count: db_doc_count,
file_size: db_file_size
file_size: db_file_size,
last_update_seq: last_update_seq,
last_update_id: last_update_id,
last_update_date: last_update_date
},
files: files
} -> %>
<section>Database documents: <%= db_doc_count %></section>
<section>Last sequence: <%= @last_update_seq %></section>
<section>Last change id: <%= @last_update_id %></section>
<section> Last change date: <%= @last_update_date %></section>
<section>Last sequence: <%= last_update_seq %></section>
<section>Last change id: <%= last_update_id %></section>
<section>Last change date: <%= last_update_date %></section>
<section>Database size: <%= Sizeable.filesize(db_file_size) %> (<%= db_file_size %> bytes)</section>
<%= case files do %>
<% :enoent -> %>
Expand Down

0 comments on commit 8976ddd

Please sign in to comment.