diff --git a/src/composables/useMediaSourceSearch.ts b/src/composables/useMediaSourceSearch.ts index a0148bf..fe370c3 100644 --- a/src/composables/useMediaSourceSearch.ts +++ b/src/composables/useMediaSourceSearch.ts @@ -1,11 +1,11 @@ // this file incoperates the actual search for the yearly frequency data export function useMediaSourceSearch() { - const { FREQUENCIES_URL } = useAPIs(); + // const { FREQUENCIES_URL } = useAPIs(); - const { authenticatedFetch } = useAuthenticatedFetch(); - // todo storeToRefs as soon this data is actually fetched - const { corpusStatistics } = useCorporaStore(); + // const { authenticatedFetch } = useAuthenticatedFetch(); + // // todo storeToRefs as soon this data is actually fetched + // const { corpusStatistics } = useCorporaStore(); // const { getWordlist } = useWordlist(); const getMediaSourceFrequencies = async (query: CorpusQuery) => { // todo implement proper mapping and returning of ifos diff --git a/src/composables/useYearlyFrequenciesSearch.ts b/src/composables/useYearlyFrequenciesSearch.ts index fbf0247..a1041a6 100644 --- a/src/composables/useYearlyFrequenciesSearch.ts +++ b/src/composables/useYearlyFrequenciesSearch.ts @@ -1,7 +1,5 @@ // this file incoperates the actual search for the yearly frequency data -import { type Ref } from "vue" - -import { useCorporaStore } from "../stores/corpora"; +import { useCorporaStore, type usedYear } from "../stores/corpora"; export function useYearlyFrequenciesSearch() { const { FREQUENCIES_URL } = useAPIs(); @@ -32,8 +30,7 @@ export function useYearlyFrequenciesSearch() { query.data.yearlyFrequencies.push({ year: Number(year), absolute: freq, - // @ts-ignore - relative: freq / corpusStatistics.avgYearlyFrequencies[Number(year)], + relative: freq / corpusStatistics.avgYearlyFrequencies[Number(year) as unknown as usedYear], }); }); query.loading.yearlyFrequencies = false; diff --git a/src/stores/corpora.ts b/src/stores/corpora.ts index e06b8b4..0dafff7 100644 --- a/src/stores/corpora.ts +++ b/src/stores/corpora.ts @@ -3,6 +3,24 @@ import { computed, type Ref, ref, watch } from "vue"; import { useAuthenticatedFetch } from "../composables/useAuthenticatedFetch"; +export type usedYear = 2005 | + 2006 | + 2007 | + 2008 | + 2009 | + 2010 | + 2012 | + 2013 | + 2014 | + 2015 | + 2016 | + 2017 | + 2018 | + 2019 | + 2020 | + 2021 | + 2022; + export const useCorporaStore = defineStore( "corpora", () => { @@ -33,6 +51,8 @@ export const useCorporaStore = defineStore( const subCorpora: Ref> = ref([]); const selectedSubCorpus: Ref = ref(null); + + const corpusStatistics = ref({ // todo fetch this data from server totalAverageFrequency: 30, @@ -55,7 +75,7 @@ export const useCorporaStore = defineStore( 2020: 5, 2021: 5, 2022: 5, - }, + } as Record, }); const { SUB_CORPUS_URL } = useAPIs();