forked from MapComplete/MapComplete
		
	Add cache to velopark entries
This commit is contained in:
		
							parent
							
								
									d149a0d31d
								
							
						
					
					
						commit
						86373b4cb8
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		| 
						 | 
					@ -641,12 +641,17 @@ export default class LinkedDataLoader {
 | 
				
			||||||
        return results
 | 
					        return results
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static veloparkCache : Record<string, Feature[]> = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Fetches all data relevant to velopark.
 | 
					     * Fetches all data relevant to velopark.
 | 
				
			||||||
     * The id will be saved as `ref:velopark`
 | 
					     * The id will be saved as `ref:velopark`
 | 
				
			||||||
     * @param url
 | 
					     * @param url
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static async fetchVeloparkEntry(url: string): Promise<Feature[]> {
 | 
					    public static async fetchVeloparkEntry(url: string): Promise<Feature[]> {
 | 
				
			||||||
 | 
					        if(this.veloparkCache[url]){
 | 
				
			||||||
 | 
					            return this.veloparkCache[url]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        const withProxyUrl = Constants.linkedDataProxy.replace("{url}", encodeURIComponent(url))
 | 
					        const withProxyUrl = Constants.linkedDataProxy.replace("{url}", encodeURIComponent(url))
 | 
				
			||||||
        const optionalPaths: Record<string, string | Record<string, string>> = {
 | 
					        const optionalPaths: Record<string, string | Record<string, string>> = {
 | 
				
			||||||
            "schema:interactionService": {
 | 
					            "schema:interactionService": {
 | 
				
			||||||
| 
						 | 
					@ -702,6 +707,7 @@ export default class LinkedDataLoader {
 | 
				
			||||||
            p["ref:velopark"] = [section]
 | 
					            p["ref:velopark"] = [section]
 | 
				
			||||||
            patched.push(LinkedDataLoader.asGeojson(p))
 | 
					            patched.push(LinkedDataLoader.asGeojson(p))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        this.veloparkCache[url] = patched
 | 
				
			||||||
        return patched
 | 
					        return patched
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue