import { PostgreSQL } from "../types" ; import { query } from "../query" ; import { number_of_running_projects_using_license , number_of_projects_with_license_applied } from "./analytics" ; export async function site_license_public_info ( db , license_id ) { const obj = await query ( { db , select : [ "title" , "description" , "expires" , "activates" , "upgrades" , "quota" , "run_limit" , "managers" , ] , table : "site_licenses" , where : { id : license_id } , one : true , } ) ; if ( ! obj ) throw Error ( `no license with id ${ license_id }` ) ; obj . running = await number_of_running_projects_using_license ( db , license_id ) ; obj . applied = await number_of_projects_with_license_applied ( db , license_id ) ; return obj ; }