import { Db } from 'mongodb' ; import { computeExperienceOverYears , computeToolsExperienceRanking } from '../compute' ; import { useCache } from '../caching' ; import { SurveyConfig , RequestContext } from '../types' ; import { Filters } from '../filters' ; import { YearAggregations } from '../compute/generic' ; interface ToolConfig { survey : SurveyConfig ; id : string ; filters ? : Filters ; } const computeToolExperience = async ( db , survey , id , filters ? ) => useCache ( computeExperienceOverYears , db , [ survey , id , filters ] ) ; export default { ToolsRankings : { experience : async ( { survey , ids , filters } , args , { db } ) => useCache ( computeToolsExperienceRanking , db , [ survey , ids , filters ] ) } , ToolExperience : { all_years : async ( { survey , id , filters } , args , { db } ) => computeToolExperience ( db , survey , id , filters ) , year : async ( { survey , id , filters } , { year } , { db } ) => { const allYears = await computeToolExperience ( db , survey , id , filters ) ; return allYears . find ( yearItem => yearItem . year === year ) ; } } } ;