|
1 | 1 | # Wikipedia Blame Implementation Notes |
2 | 2 |
|
3 | 3 | ## Search Algorithm Implementation |
| 4 | + |
4 | 5 | - Randomized sampling approach (10% of revisions or at least 5 revisions) for efficiency |
5 | 6 | - Fallback to exhaustive batch search when needed |
6 | 7 | - Parallel fetching of revisions using Promise.all to improve performance |
|
9 | 10 | ## Key Components |
10 | 11 |
|
11 | 12 | ### WikipediaAPI Service |
| 13 | + |
12 | 14 | ```typescript |
13 | 15 | // Core functions for interacting with Wikipedia API |
14 | 16 | async getRevisionTexts(revIds: ReadonlyArray<number>, lang: WikiLanguage = 'en'): Promise<ReadonlyArray<RevisionResult>> |
15 | 17 | async getAllRevisions(pageTitle: string, lang: WikiLanguage = 'en'): Promise<ReadonlyArray<number>> |
16 | 18 | ``` |
17 | 19 |
|
18 | 20 | ### RevisionFinder Utility |
| 21 | + |
19 | 22 | ```typescript |
20 | 23 | // Non-destructive Fisher-Yates shuffle |
21 | | -function shuffleArray<T>(array: ReadonlyArray<T>): ReadonlyArray<T> |
| 24 | +function shuffleArray<T>(array: ReadonlyArray<T>): ReadonlyArray<T>; |
22 | 25 |
|
23 | 26 | // Main search function with sampling approach |
24 | 27 | async function findOneOccurrence( |
25 | | - targetText: string, |
26 | | - revList: ReadonlyArray<number>, |
27 | | - lang: WikiLanguage = 'en' |
28 | | -): Promise<number | null> |
| 28 | + targetText: string, |
| 29 | + revList: ReadonlyArray<number>, |
| 30 | + lang: WikiLanguage = 'en' |
| 31 | +): Promise<number | null>; |
29 | 32 |
|
30 | 33 | // Fallback exhaustive search |
31 | 34 | async function exhaustiveSearch( |
32 | | - revList: ReadonlyArray<number>, |
33 | | - targetText: string, |
34 | | - lang: WikiLanguage = 'en' |
35 | | -): Promise<number | null> |
| 35 | + revList: ReadonlyArray<number>, |
| 36 | + targetText: string, |
| 37 | + lang: WikiLanguage = 'en' |
| 38 | +): Promise<number | null>; |
36 | 39 | ``` |
37 | 40 |
|
38 | 41 | ### React Components |
| 42 | + |
39 | 43 | - **SearchForm**: Handles user input with trimming on change |
40 | 44 | - **LanguageSelector**: Toggles between English and Japanese Wikipedia with base URLs displayed |
41 | 45 | - **ResultView**: Displays search results with links to the specific revision |
42 | 46 |
|
43 | 47 | ## Technical Decisions |
| 48 | + |
44 | 49 | - Used ReadonlyArray for better immutability throughout the codebase |
45 | 50 | - Implemented trimming of input strings on change rather than just on submit |
46 | 51 | - Added language selector with base URLs displayed for clarity (en.wikipedia.org/ja.wikipedia.org) |
47 | 52 | - Structured the app as a minimal SPA without router or complex frameworks |
48 | 53 | - Used TypeScript types instead of interfaces for consistency |
49 | 54 |
|
50 | 55 | ## Implementation Progress |
| 56 | + |
51 | 57 | - Core functionality for finding one text occurrence implemented |
52 | 58 | - Basic UI with search form and results display |
53 | 59 | - CSS styling with CSS variables for theming and responsive design |
54 | 60 | - Error handling for API calls and search process |
55 | 61 |
|
56 | 62 | ## Future Work |
| 63 | + |
57 | 64 | - Implement tests using real Wikipedia endpoints (with mocking) |
58 | 65 | - Add functionality to find first/last addition/deletion of text |
59 | 66 | - Add user selection to search further |
|
0 commit comments