mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-20 00:35:22 +00:00
Fix wakatime extension responses
This commit is contained in:
parent
638dfa6f9a
commit
f864d6d52e
2 changed files with 10 additions and 24 deletions
|
|
@ -41,30 +41,16 @@ class Api::Hackatime::V1::HackatimeController < ApplicationController
|
|||
def status_bar_today
|
||||
hbt = @user.heartbeats.today
|
||||
|
||||
# TODO: This is a temporary response to the status bar.
|
||||
render json: {
|
||||
"data": {
|
||||
"grand_total": {
|
||||
"decimal": "yolo",
|
||||
"digital": "wahoo",
|
||||
"hours": hbt.duration_seconds / 3600,
|
||||
"minutes": (hbt.duration_seconds % 3600) / 60,
|
||||
"text": @user.format_extension_text(hbt.duration_seconds),
|
||||
"total_seconds": hbt.duration_seconds
|
||||
},
|
||||
"categories": hbt.distinct.pluck(:category),
|
||||
"dependencies": hbt.distinct.pluck(:dependencies),
|
||||
"editors": hbt.distinct.pluck(:editor),
|
||||
"languages": hbt.distinct.pluck(:language),
|
||||
"machines": hbt.distinct.pluck(:machine),
|
||||
"operating_systems": hbt.distinct.pluck(:operating_system),
|
||||
"projects": hbt.distinct.pluck(:project),
|
||||
"range": {
|
||||
"text": "Today",
|
||||
"timezone": "UTC"
|
||||
result = {
|
||||
data: {
|
||||
grand_total: {
|
||||
text: @user.format_extension_text(hbt.duration_seconds),
|
||||
total_seconds: hbt.duration_seconds
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render json: result
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ class User < ApplicationRecord
|
|||
|
||||
def format_extension_text(duration)
|
||||
case hackatime_extension_text_type
|
||||
when :simple_text
|
||||
when "simple_text"
|
||||
return "Start coding to track your time" if duration.zero?
|
||||
::ApplicationController.helpers.short_time_simple(duration)
|
||||
when :clock_emoji
|
||||
when "clock_emoji"
|
||||
::ApplicationController.helpers.time_in_emoji(duration)
|
||||
when :compliment_text
|
||||
when "compliment_text"
|
||||
"You're doing great!"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue