original_string: public static function fill_firstanalyses_cache(int $modelid, ?int $analysableid = null) {
          global $DB;
  
          // Using composed keys instead of cache $identifiers because of MDL-65358.
          $primarykey = $DB->sql_concat($modelid, "'_'", 'analysableid');
          $sql = "SELECT $primarykey AS id, MIN(firstanalysis) AS firstanalysis
                    FROM {analytics_used_analysables} aua
                   WHERE modelid = :modelid";
          $params = ['modelid' => $modelid];
  
          if ($analysableid) {
              $sql .= " AND analysableid = :analysableid";
              $params['analysableid'] = $analysableid;
          }
  
          $sql .= " GROUP BY modelid, analysableid ORDER BY analysableid";
  
          $firstanalyses = $DB->get_records_sql($sql, $params);
          if ($firstanalyses) {
              $cache = \cache::make('core', 'modelfirstanalyses');
  
              $firstanalyses = array_map(function($record) {
                  return $record->firstanalysis;
              }, $firstanalyses);
  
              $cache->set_many($firstanalyses);
          }
  
          return $firstanalyses;
      }
code: public static function fill_firstanalyses_cache(int $modelid, ?int $analysableid = null) {
          global $DB;
  
          // Using composed keys instead of cache $identifiers because of MDL-65358.
          $primarykey = $DB->sql_concat($modelid, "'_'", 'analysableid');
          $sql = "SELECT $primarykey AS id, MIN(firstanalysis) AS firstanalysis
                    FROM {analytics_used_analysables} aua
                   WHERE modelid = :modelid";
          $params = ['modelid' => $modelid];
  
          if ($analysableid) {
              $sql .= " AND analysableid = :analysableid";
              $params['analysableid'] = $analysableid;
          }
  
          $sql .= " GROUP BY modelid, analysableid ORDER BY analysableid";
  
          $firstanalyses = $DB->get_records_sql($sql, $params);
          if ($firstanalyses) {
              $cache = \cache::make('core', 'modelfirstanalyses');
  
              $firstanalyses = array_map(function($record) {
                  return $record->firstanalysis;
              }, $firstanalyses);
  
              $cache->set_many($firstanalyses);
          }
  
          return $firstanalyses;
      }
code_tokens: public static function fill_firstanalyses_cache ( int $ modelid , ? int $ analysableid = null ) { global $ DB ; // Using composed keys instead of cache $identifiers because of MDL-65358. $ primarykey = $ DB -> sql_concat ( $ modelid , "'_'" , 'analysableid' ) ; $ sql = "SELECT $primarykey AS id, MIN(firstanalysis) AS firstanalysis
                    FROM {analytics_used_analysables} aua
                   WHERE modelid = :modelid" ; $ params = [ 'modelid' => $ modelid ] ; if ( $ analysableid ) { $ sql .= " AND analysableid = :analysableid" ; $ params [ 'analysableid' ] = $ analysableid ; } $ sql .= " GROUP BY modelid, analysableid ORDER BY analysableid" ; $ firstanalyses = $ DB -> get_records_sql ( $ sql , $ params ) ; if ( $ firstanalyses ) { $ cache = \ cache :: make ( 'core' , 'modelfirstanalyses' ) ; $ firstanalyses = array_map ( function ( $ record ) { return $ record -> firstanalysis ; } , $ firstanalyses ) ; $ cache -> set_many ( $ firstanalyses ) ; } return $ firstanalyses ; }
docstring: Fills a cache containing the first time each analysable in the provided model was analysed.
  
  @param int $modelid
  @param int|null $analysableid
  @return null
docstring_tokens: Fills a cache containing the first time each analysable in the provided model was analysed .