code: public function getAllActiveQuery(Production $production): Query
      {
          $qb = $this->createQueryBuilder('p');
  
          return $qb
              ->join('p.groups', 'g')
  
              // Add conditions.
              ->andWhere($qb->expr()->eq('g', ':group'))
              ->andWhere($qb->expr()->eq('p.active', ':active'))
              ->andWhere($qb->expr()->isNull('p.parent'))
              ->andWhere($qb->expr()->orX(
                  $qb->expr()->isNull('p.expiry'),
                  $qb->expr()->gt('p.expiry', ':now')
              ))
  
              // Add parameters.
              ->setParameter('group', $production)
              ->setParameter('active', true)
              ->setParameter('now', new \DateTime())
  
              // Order by and get results.
              ->orderBy('p.pinned', 'DESC')
              ->addOrderBy('p.created', 'DESC')
              ->getQuery();
      }
docs: Query to find all active posts.
  
  @param Production $production The production to search for.
  
  @return Query