Tatsh / kate-wakatime

Kate plugin to interface with WakaTime

Home Page:https://tatsh.github.io/kate-wakatime/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kate slowness with errors

Mte90 opened this issue · comments

So I was getting some slowness inside Kate, running with shell I am getting this errors.

wakatime: File path: "/home/mte90/Desktop/Prog/GameShell/missions/pipe_intro_book_of_potions/01_head/goal/en.txt"
wakatime: Single heartbeat in array: QJsonDocument({"category":"coding","entity":"HIDDEN.txt","language":"Normal","project":"01_head","time":1654088388,"type":"file"})
offlinequeue: connect(): Returning existing db instance
wakatime: File path: "/home/mte90/Desktop/Prog/GameShell/missions/pipe_intro_book_of_potions/01_head/goal/en.txt"
wakatime: Single heartbeat in array: QJsonDocument({"category":"coding","entity":"HIDDEN.txt","language":"Normal","project":"01_head","time":1654088388,"type":"file"})
offlinequeue: connect(): Returning existing db instance
wakatime: File path: "/home/mte90/Desktop/Prog/GameShell/missions/pipe_intro_book_of_potions/01_head/goal/en.txt"
wakatime: Single heartbeat in array: QJsonDocument({"category":"coding","entity":"HIDDEN.txt","language":"Normal","project":"01_head","time":1654088388,"type":"file"})
offlinequeue: connect(): Returning existing db instance
wakatime: Status code: 301
wakatime: Could not parse response. All responses are expected to be JSON serialised
wakatime: Status code: 301
wakatime: Could not parse response. All responses are expected to be JSON serialised
wakatime: Status code: 301
wakatime: Could not parse response. All responses are expected to be JSON serialised

The line

const QJsonDocument doc = QJsonDocument::fromJson(contents);

This line require a change as this file was moved https://github.com/Tatsh/kate-wakatime/blob/master/wakatimeplugin.cpp#L36

#include <KF5/KTextEditor/ktexteditor_version.h>

My issue is that my API URL has a initial slash (https://wakapi.dev/api//v1/users/current/heartbeats.bulk) but this will be appended with the endpoint URL so doesn't work.
The URL need to be sanitized, I am trying with url.adjusted(QUrl::NormalizePathSegments);

Also on Kate starting I have tons of this:

offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788062-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788063-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788092-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788096-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788097-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788098-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788101-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788102-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788103-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788107-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788108-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788110-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788111-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788112-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788116-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788119-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788122-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788123-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788124-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788130-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788132-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788133-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788134-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788141-file-coding-planet--HIDDEN.php-0'"
offlinequeue: connect(): Returning existing db instance
offlinequeue: pop(): executed "DELETE FROM heartbeat_2 WHERE id = '1626788142-file-coding-planet--HIDDEN.php-0'"

Maybe instead to do various queries is enough to do just one.

commented

I will accept a PR to switch over to wakatime-cli #22. I did at one time have a branch for this change (back when wakatime was Python-based) but I found it to be oddly slow.

The biggest concern for the subprocess code is to make certain that the thread is locked/unlocked properly so it cannot run twice simultaneously and does not double post.

I still definitely prefer calling their API without calling a subprocess but ever since adding the heartbeat database code and then WakaTime switching to Go with BDB, this has become difficult to maintain.