MCPcopy Index your code
hub / github.com/LeetCode-OpenSource/vscode-leetcode / getSessionList

Function getSessionList

src/commands/session.ts:10–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import { DialogOptions, DialogType, promptForOpenOutputChannel, promptForSignIn } from "../utils/uiUtils";
9
10export async function getSessionList(): Promise<ISession[]> {
11 const signInStatus: string | undefined = leetCodeManager.getUser();
12 if (!signInStatus) {
13 promptForSignIn();
14 return [];
15 }
16 const result: string = await leetCodeExecutor.listSessions();
17 const lines: string[] = result.split("\n");
18 const sessions: ISession[] = [];
19 const reg: RegExp = /(.?)\s*(\d+)\s+(.*)\s+(\d+ \(\s*\d+\.\d+ %\))\s+(\d+ \(\s*\d+\.\d+ %\))/;
20 for (const line of lines) {
21 const match: RegExpMatchArray | null = line.match(reg);
22 if (match && match.length === 6) {
23 sessions.push({
24 active: !!(match[1].trim()),
25 id: match[2].trim(),
26 name: match[3].trim(),
27 acQuestions: match[4].trim(),
28 acSubmits: match[5].trim(),
29 });
30 }
31 }
32 return sessions;
33}
34
35export async function manageSessions(): Promise<void> {
36 const choice: IQuickItemEx<ISession | string> | undefined = await vscode.window.showQuickPick(parseSessionsToPicks(true /* includeOperation */));

Callers 1

parseSessionsToPicksFunction · 0.85

Calls 3

promptForSignInFunction · 0.90
getUserMethod · 0.80
listSessionsMethod · 0.80

Tested by

no test coverage detected