forked from MapComplete/MapComplete
		
	Scripts(community_index): create script to update community index files, create weekly data maintenance script
This commit is contained in:
		
							parent
							
								
									36a9b49c66
								
							
						
					
					
						commit
						7bddaa7d4c
					
				
					 11 changed files with 412 additions and 141 deletions
				
			
		| 
						 | 
				
			
			@ -6,8 +6,10 @@
 | 
			
		|||
  import ContactLink from "./ContactLink.svelte"
 | 
			
		||||
  import { GeoOperations } from "../../Logic/GeoOperations"
 | 
			
		||||
  import Translations from "../i18n/Translations"
 | 
			
		||||
  import ToSvelte from "../Base/ToSvelte.svelte"
 | 
			
		||||
  import type { Feature, Geometry, GeometryCollection } from "@turf/turf"
 | 
			
		||||
  import type { FeatureCollection, Polygon } from "geojson"
 | 
			
		||||
  import type { CommunityResource } from "../../Logic/Web/CommunityIndex"
 | 
			
		||||
  import Tr from "../Base/Tr.svelte"
 | 
			
		||||
 | 
			
		||||
  export let location: Store<{ lat: number; lon: number }>
 | 
			
		||||
  const tileToFetch: Store<string> = location.mapD((l) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +22,10 @@
 | 
			
		|||
  >([])
 | 
			
		||||
 | 
			
		||||
  tileToFetch.addCallbackAndRun(async (url) => {
 | 
			
		||||
    const data = await Utils.downloadJsonCached(url, 24 * 60 * 60)
 | 
			
		||||
    const data = await Utils.downloadJsonCached<FeatureCollection<Polygon, {
 | 
			
		||||
      nameEn: string,
 | 
			
		||||
      resources: Record<string, CommunityResource>
 | 
			
		||||
    }>>(url, 24 * 60 * 60)
 | 
			
		||||
    if (data === undefined) {
 | 
			
		||||
      return
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -29,15 +34,13 @@
 | 
			
		|||
 | 
			
		||||
  const filteredResources = resources.map(
 | 
			
		||||
    (features) =>
 | 
			
		||||
      features.filter((f) => {
 | 
			
		||||
        return GeoOperations.inside([location.data.lon, location.data.lat], f)
 | 
			
		||||
      }),
 | 
			
		||||
      features.filter((f) => GeoOperations.inside([location.data.lon, location.data.lat], f)),
 | 
			
		||||
    [location]
 | 
			
		||||
  )
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<div>
 | 
			
		||||
  <ToSvelte construct={t.intro} />
 | 
			
		||||
  <Tr t={t.intro} />
 | 
			
		||||
  {#each $filteredResources as feature}
 | 
			
		||||
    <ContactLink country={feature.properties} />
 | 
			
		||||
  {/each}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,23 +3,18 @@
 | 
			
		|||
  // The _properties_ of a community feature
 | 
			
		||||
  import Locale from "../i18n/Locale.js"
 | 
			
		||||
  import Translations from "../i18n/Translations"
 | 
			
		||||
  import ToSvelte from "../Base/ToSvelte.svelte"
 | 
			
		||||
  import * as native from "../../assets/language_native.json"
 | 
			
		||||
  import { TypedTranslation } from "../i18n/Translation"
 | 
			
		||||
  import Tr from "../Base/Tr.svelte"
 | 
			
		||||
  import type { CommunityResource } from "../../Logic/Web/CommunityIndex"
 | 
			
		||||
 | 
			
		||||
  const availableTranslationTyped: TypedTranslation<{ native: string }> =
 | 
			
		||||
    Translations.t.communityIndex.available
 | 
			
		||||
  const availableTranslation = availableTranslationTyped.OnEveryLanguage((s, ln) =>
 | 
			
		||||
    s.replace("{native}", native[ln] ?? ln)
 | 
			
		||||
  )
 | 
			
		||||
  export let country: { resources; nameEn: string }
 | 
			
		||||
  let resources: {
 | 
			
		||||
    id: string
 | 
			
		||||
    resolved: Record<string, string>
 | 
			
		||||
    languageCodes: string[]
 | 
			
		||||
    type: string
 | 
			
		||||
  }[] = []
 | 
			
		||||
  export let country: { resources: Record<string, CommunityResource>; nameEn: string }
 | 
			
		||||
  let resources: CommunityResource[] = []
 | 
			
		||||
  $: resources = Array.from(Object.values(country?.resources ?? {}))
 | 
			
		||||
 | 
			
		||||
  const language = Locale.language
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue