@@ -69,6 +69,27 @@ function setupReleasedModels() {
6969 return isReleasedModels ;
7070}
7171
72+ /**
73+ * @param {ModelRecord[] } models
74+ */
75+ function getReleasedModels ( models ) {
76+ /** @type {Map<string, ModelRecord> } */
77+ const langPairs = new Map ( ) ;
78+ for ( const model of models ) {
79+ if ( getReleaseChannels ( model ) ?. release ) {
80+ const langPair = model . fromLang + "-" + model . toLang ;
81+ const existingModel = langPairs . get ( langPair ) ;
82+ if (
83+ ! existingModel ||
84+ versionCompare ( model . version , existingModel . version ) > 0
85+ ) {
86+ langPairs . set ( langPair , model ) ;
87+ }
88+ }
89+ }
90+ return ( models = [ ...langPairs . values ( ) ] ) ;
91+ }
92+
7293async function main ( ) {
7394 getElement ( "counts" ) . style . display = "table" ;
7495
@@ -84,7 +105,6 @@ async function main() {
84105 exposeAsGlobal ( "records" , records . data ) ;
85106
86107 const attachmentsByKey = getAttachmentsByKey ( records . data ) ;
87- countModels ( records . data ) ;
88108
89109 /** @type {EvalResults } */
90110 const cometResults = await fetchJSON (
@@ -105,9 +125,13 @@ async function main() {
105125 /** @type {Map<string, ModelEntry> } */
106126 const modelsMap = new Map ( ) ;
107127 let models = records . data . filter ( ( record ) => record . fileType === "model" ) ;
128+ const releasedModels = getReleasedModels ( models ) ;
129+
130+ countModels ( models , releasedModels ) ;
108131
109132 if ( isReleasedModels ) {
110- models = models . filter ( ( model ) => getReleaseChannels ( model ) ?. release ) ;
133+ // Get the released model with the latest version.
134+ models = releasedModels ;
111135 }
112136 exposeAsGlobal ( "models" , models ) ;
113137
@@ -475,11 +499,11 @@ function getReleaseChannels(model) {
475499 } ;
476500 case "env.appinfo.OS != 'Android' || env.channel != 'release'" :
477501 return {
478- release : false ,
502+ release : true ,
479503 beta : true ,
480504 nightly : true ,
481505 android : false ,
482- label : "Beta Desktop" ,
506+ label : "Release ( Desktop) " ,
483507 } ;
484508 case "env.channel == 'default' || env.channel == 'nightly'" :
485509 return {
@@ -607,38 +631,36 @@ function getAttachmentsByKey(records) {
607631}
608632
609633/**
610- * @param {ModelRecord[] } records
634+ * @param {ModelRecord[] } allModels
635+ * @param {ModelRecord[] } releasedModels
611636 */
612- function countModels ( records ) {
637+ function countModels ( allModels , releasedModels ) {
613638 const fromProd = new Set ( ) ;
614- const fromNightly = new Set ( ) ;
639+ const fromAll = new Set ( ) ;
615640 const toProd = new Set ( ) ;
616- const toNightly = new Set ( ) ;
641+ const toAll = new Set ( ) ;
617642
618- for ( const record of records ) {
619- const isRelease =
620- ! record . filter_expression ||
621- record . filter_expression . includes ( "env.channel == 'release'" ) ;
622- if ( record . fromLang == "en" ) {
623- if ( isRelease ) {
624- toProd . add ( record . toLang ) ;
625- } else {
626- toNightly . add ( record . toLang ) ;
627- }
643+ for ( const model of releasedModels ) {
644+ if ( model . fromLang == "en" ) {
645+ toProd . add ( model . toLang ) ;
628646 } else {
629- if ( isRelease ) {
630- fromProd . add ( record . fromLang ) ;
631- } else {
632- fromNightly . add ( record . fromLang ) ;
633- }
647+ fromProd . add ( model . fromLang ) ;
648+ }
649+ }
650+
651+ for ( const model of allModels ) {
652+ if ( model . fromLang == "en" ) {
653+ toAll . add ( model . toLang ) ;
654+ } else {
655+ fromAll . add ( model . fromLang ) ;
634656 }
635657 }
636658
637- const toNightlyOnly = toNightly . difference ( toProd ) ;
638- const fromNightlyOnly = fromNightly . difference ( fromProd ) ;
659+ const toNightly = toAll . difference ( toProd ) ;
660+ const fromNightly = fromAll . difference ( fromProd ) ;
639661
640662 getElement ( "fromProd" ) . innerText = String ( fromProd . size ) ;
641663 getElement ( "toProd" ) . innerText = String ( toProd . size ) ;
642- getElement ( "fromNightly" ) . innerText = String ( toNightlyOnly . size ) ;
643- getElement ( "toNightly" ) . innerText = String ( fromNightlyOnly . size ) ;
664+ getElement ( "fromNightly" ) . innerText = String ( toNightly . size ) ;
665+ getElement ( "toNightly" ) . innerText = String ( fromNightly . size ) ;
644666}
0 commit comments