Skip to content

Commit

Permalink
Generic method name: it handles past and future time
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Mar 28, 2023
1 parent ce0cf6d commit 384b210
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/app/components/fuzzy_time_component.html.haml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
%time.fuzzy-time{ title: localize(time.utc) }
= human_time_ago
= human_time
2 changes: 1 addition & 1 deletion src/api/app/components/fuzzy_time_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(time:)
@time = time.utc
end

def human_time_ago
def human_time
now = Time.now.utc
diff = now - time

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/maintenance_incident_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def outgoing_request_links(requests)
tag.i(nil, class: "fas fa-flag pe-1 request-flag-#{request['state']}", title: "Release request in state '#{request['state']}'")
end,
# rubocop:disable Rails/OutputSafety
FuzzyTimeComponent.new(time: request.created_at).human_time_ago.html_safe
FuzzyTimeComponent.new(time: request.created_at).human_time.html_safe
# rubocop:enable Rails/OutputSafety
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%p
The previous request
= link_to(request['id'], request_show_path(project, package, request['id']))
was declined #{FuzzyTimeComponent.new(time: request['when']).human_time_ago} by
was declined #{FuzzyTimeComponent.new(time: request['when']).human_time} by
= user_with_realname_and_icon(request['decliner'], short: true)
with the following message:
%pre= request['comment']
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/shared/bs_requests/index.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"data": [
<% table_rows.each.with_index do |row, index| %>
[
"<%= escape_javascript(FuzzyTimeComponent.new(time: row.created_at).human_time_ago) %>",
"<%= escape_javascript(FuzzyTimeComponent.new(time: row.created_at).human_time) %>",
<% cache "request-table-row-#{row.id}-#{row.updated_at.to_i}" do %>
"<%= escape_javascript(project_or_package_link(project: row.source_project, package: row.source_package, creator: row.creator, trim_to: 40, short: true)) %>",
"<%= escape_javascript(target_project_link(row)) %>",
Expand Down

0 comments on commit 384b210

Please sign in to comment.