Skip to content

Add a fix language function #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

JeffreyWangDev
Copy link
Contributor

Added a function to rename the language name to consolidate the same language, e.g., js and javascript to JavaScript.

Bug report: #402

Added a function to rename the language name to consolidate the same language EX js and javascript to Javascript.
Bug report: hackclub#402
I literally removed 2 lines of nothing bc the linter was mad

Hopefully the linter is happy now
I removed 2 tabs from line 135

The linter was still mad, I hope to all powerful that its happy now
@JeffreyWangDev
Copy link
Contributor Author

Note: This does not fix any old heartbeats. I don't know how/where to write a script to do so.

@JeffreyWangDev
Copy link
Contributor Author

JeffreyWangDev commented Aug 5, 2025

Used this to test out this function

$time = [Math]::Floor([decimal](Get-Date(Get-Date).ToUniversalTime()-uformat '%s'))
$heartbeat = @{
    type = 'coding'
    time = $time
    entity = 'test.js'
    language = 'js'
    project = 'test-project'
}

$response = Invoke-RestMethod -Uri "http://localhost:3000/api/hackatime/v1/users/current/heartbeats" `
    -Method Post `
    -Headers @{Authorization="Bearer ea23e393-574c-454f-8927-a4584ede0bda"} `
    -ContentType 'application/json' `
    -Body "[$($heartbeat | ConvertTo-Json)]"
    
$heartbeat = @{
    type = 'coding'
    time = $time
    entity = 'test.js'
    language = 'JavaSCRIPT'
    project = 'test-project'
}
$response = Invoke-RestMethod -Uri "http://localhost:3000/api/hackatime/v1/users/current/heartbeats" `
    -Method Post `
    -Headers @{Authorization="Bearer ea23e393-574c-454f-8927-a4584ede0bda"} `
    -ContentType 'application/json' `
    -Body "[$($heartbeat | ConvertTo-Json)]"

It worked on my side with JS and Java

image

@maxwofford
Copy link
Member

I like the initial approach, but this is going to take a little bit more thinking. We need to set this up in a way where we don't clobber any data. The raw fields being sent to us shouldn't be rewritten without backing them up!

@JeffreyWangDev
Copy link
Contributor Author

Il change it so it does the renaming on the UI side of it, would that be better?

@maxwofford
Copy link
Member

@JeffreyWangDev if you can get away with that, sure! I imagine it's going to be hard to get everything though because there are some more complex things like the graphs that generate on the frontend based on SQL queries. Try it out and see how possible it is.

The other option is something like a "raw_language" and "language" field- the "raw_language" is what comes in originally, the "language" is the one we remap

Added a function to strings to rename the language to a universal name in the main home page
@JeffreyWangDev
Copy link
Contributor Author

Idk if it works in other places cause I didnt put it in other places. I don't really have access to other places like the admin pages.

I removed 3 spaces bc linter was mad
Fixed the filters working with the new name thing
@JeffreyWangDev
Copy link
Contributor Author

I got the graphs and the dropdown to reduce languages by renaming it in the heartbeats

@JeffreyWangDev
Copy link
Contributor Author

#358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants