mirror of
https://gitlab.com/aviortheking/code-stats-vscode.git
synced 2025-08-03 23:31:59 +00:00
@@ -13,8 +13,8 @@ if (typeof fetch === 'undefined') {
|
||||
}
|
||||
|
||||
export class CodeStatsAPI {
|
||||
private API_KEY = null;
|
||||
private USER_NAME = null;
|
||||
private API_KEY?: string;
|
||||
private USER_NAME?: string;
|
||||
private UPDATE_URL = "https://codestats.net/api";
|
||||
private headers: Record<string, string> = {
|
||||
"Content-Type": "application/json"
|
||||
@@ -47,7 +47,6 @@ export class CodeStatsAPI {
|
||||
return null;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:typedef
|
||||
const data = new ApiJSON(new Date());
|
||||
|
||||
for (let lang of pulse.xps.keys()) {
|
||||
@@ -86,7 +85,7 @@ export class CodeStatsAPI {
|
||||
|
||||
class ApiJSON {
|
||||
constructor(date: Date) {
|
||||
this.coded_at = getISOTimestamp(new Date());
|
||||
this.coded_at = getISOTimestamp(date);
|
||||
this.xps = new Array<ApiXP>();
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
import { CancellationToken, Event, ExtensionContext, TextDocumentContentProvider, Uri, workspace } from "vscode"
|
||||
import { CancellationToken, Event, ExtensionContext, TextDocumentContentProvider, Uri } from "vscode"
|
||||
import { CodeStatsAPI } from "./code-stats-api"
|
||||
import profileHtmlEex from './profile.html.eex'
|
||||
|
||||
@@ -16,9 +16,9 @@ export class ProfileProvider implements TextDocumentContentProvider {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
provideTextDocumentContent(uri: Uri, token: CancellationToken): string | Thenable<string> {
|
||||
provideTextDocumentContent(_uri: Uri, token: CancellationToken): string | Thenable<string> {
|
||||
|
||||
if (token.isCancellationRequested) return;
|
||||
if (token.isCancellationRequested) return '';
|
||||
|
||||
const LEVEL_FACTOR = 0.025;
|
||||
|
||||
|
@@ -6,7 +6,7 @@ export class Pulse {
|
||||
}
|
||||
|
||||
public getXP(language: string): number {
|
||||
let xp: number = this.xps.get(language);
|
||||
let xp = this.xps.get(language);
|
||||
|
||||
if (xp === null || xp === undefined) {
|
||||
return 0;
|
||||
|
@@ -11,7 +11,7 @@ export class XpCounter {
|
||||
private combinedDisposable: Disposable;
|
||||
private statusBarItem: StatusBarItem;
|
||||
private pulse: Pulse;
|
||||
private api: CodeStatsAPI;
|
||||
private api!: CodeStatsAPI;
|
||||
private updateTimeout: any;
|
||||
|
||||
// wait 10s after each change in the document before sending an update
|
||||
@@ -33,10 +33,8 @@ export class XpCounter {
|
||||
|
||||
let subscriptions: Disposable[] = [];
|
||||
|
||||
if (!this.statusBarItem) {
|
||||
this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
|
||||
this.statusBarItem.command = "code-stats.profile";
|
||||
}
|
||||
this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
|
||||
this.statusBarItem.command = "code-stats.profile";
|
||||
|
||||
subscriptions.push(workspace.registerTextDocumentContentProvider('code-stats', new ProfileProvider(context, this.api)));
|
||||
|
||||
@@ -166,9 +164,9 @@ export class XpCounter {
|
||||
return;
|
||||
}
|
||||
|
||||
const apiKey: string = config.get("apikey");
|
||||
const apiURL: string = config.get("apiurl");
|
||||
const userName: string = config.get("username");
|
||||
const apiKey = config.get("apikey") as string;
|
||||
const apiURL = config.get("apiurl") as string;
|
||||
const userName = config.get("username") as string;
|
||||
|
||||
console.log(
|
||||
`code-stats-vscode setting up:
|
||||
@@ -178,9 +176,7 @@ export class XpCounter {
|
||||
`
|
||||
);
|
||||
|
||||
if(this.api != null )
|
||||
this.api.updateSettings(apiKey, apiURL, userName);
|
||||
else
|
||||
this.api = new CodeStatsAPI(apiKey,apiURL,userName);
|
||||
if(this.api != null ) this.api.updateSettings(apiKey, apiURL, userName);
|
||||
else this.api = new CodeStatsAPI(apiKey,apiURL,userName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user