improved UI
This commit is contained in:
1 parent
520fab5c93
commit
e9da24b54d
13 files changed
+491
-32
No files matched your search
@@ -0,0 +1,41 @@
|
||||
|
||||
export type MatchInfo = {
|
||||
id: string,
|
||||
originalVideoUrl: string,
|
||||
matchDate: string,
|
||||
label: string
|
||||
}
|
||||
|
||||
export interface MatchService {
|
||||
|
||||
getAllMatchInfo(): AsyncIterator<MatchInfo>;
|
||||
getMatchInfoById(id: string): Promise<MatchInfo|undefined>;
|
||||
|
||||
}
|
||||
|
||||
export class FileMatchService implements MatchService{
|
||||
|
||||
readonly #indexFile: string
|
||||
|
||||
constructor(indexFile: string) {
|
||||
this.#indexFile = indexFile;
|
||||
}
|
||||
|
||||
async *getAllMatchInfo(): AsyncIterator<MatchInfo>{
|
||||
const data = await Deno.readTextFile(this.#indexFile)
|
||||
const ret = JSON.parse(data) as {matches: MatchInfo[]}
|
||||
yield* ret.matches
|
||||
}
|
||||
|
||||
async getMatchInfoById(id: string): Promise<MatchInfo|undefined>{
|
||||
for await(const mi of this.getAllMatchInfo()){
|
||||
if(mi.id === id){
|
||||
return mi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user