-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
128 additions
and
1,884 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"USERID_SET": [] | ||
"USERID_SET": ["223796"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { getProblemSet } from "./webcrawler"; | ||
import { Problem, ProblemSetMap } from "./problem"; | ||
|
||
export class Query { | ||
private problemSet: ProblemSetMap; | ||
|
||
private constructor(Set : ProblemSetMap) { | ||
this.problemSet = Set; | ||
} | ||
|
||
static async init() : Promise<Query> { | ||
const Set : ProblemSetMap = await getProblemSet(); | ||
return new Query(Set); | ||
} | ||
|
||
public getProblemSet(): ProblemSetMap { | ||
return this.problemSet; | ||
} | ||
|
||
public getProblem(name: string): Problem | null{ | ||
if (!this.problemSet) { | ||
return null; | ||
} | ||
|
||
for (const key in this.problemSet) { | ||
if (key === name) { | ||
return this.problemSet[key]; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,52 @@ | ||
export interface User { | ||
import { getUserName, getAcceptedNum, getAcceptSet } from "./webcrawler"; | ||
|
||
|
||
export class User{ | ||
|
||
Name: string; | ||
Id: string; | ||
Accept: number; | ||
AcceptProblem: number[]; | ||
} | ||
AcceptProblem: Set<string>; | ||
|
||
private constructor(name: string, id: string, accept: number, acceptProblem: Set<string>) { | ||
this.Name = name; | ||
this.Id = id; | ||
this.Accept = accept; | ||
this.AcceptProblem = acceptProblem; | ||
} | ||
|
||
static async createUser(id: string): Promise<User> { | ||
|
||
const name : string = await getUserName(id); | ||
const accept : number= await getAcceptedNum(id); | ||
const acceptProblem : Set<string> = await getAcceptSet(id); | ||
|
||
return new User(name, id, accept, acceptProblem); | ||
} | ||
|
||
static async loadUser(idSets : string []) : Promise<User[]> { | ||
const users : User[] = []; | ||
for (const id of idSets) { | ||
users.push(await User.createUser(id)); | ||
} | ||
return users; | ||
} | ||
|
||
public diffSets (newSet: Set<string>): Set<string> { | ||
const diff = new Set<string>(); | ||
for (const item of newSet) if (!this.AcceptProblem.has(item)) diff.add(item); | ||
for (const item of this.AcceptProblem) if (!newSet.has(item)) diff.add(item); | ||
return diff; | ||
} | ||
|
||
public equalSets (newSet : Set<string>): boolean { | ||
return this.diffSets(newSet).size === 0; | ||
} | ||
|
||
public updateAccept(newAcceptProblem: Set<string>): void { | ||
for (const problem of newAcceptProblem) { | ||
this.AcceptProblem.add(problem); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters