<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _fetch_pageviews(self, storage, year, week, ip_users=False):
 """ Fetch PageViews from Elasticsearch. :param time_from: Staring at timestamp. :param time_to: To timestamp """

        prefix = 'Pageviews'
        if ip_users:
            query_add = "AND !(bot:True) AND (id_user:0)"
            prefix += '_IP'
        else:
            query_add = "AND !(bot:True) AND !(id_user:0)"
        store = self.storage.get(prefix, year, week)
        if not self.config['overwrite_files'] and store.does_file_exist():
            logger.debug("File already exist, skip: {}-{}".format(year, week))
            return

        store.open('overwrite')

        time_from, time_to = get_week_dates(year, week, as_timestamp=True)
        es_type = "events.pageviews"
        es_query = self.ES_QUERY % {'timestamp_start': time_from * 1000,
                                    'timestamp_end': time_to * 1000,
                                    'event_name': es_type,
                                    'query_add': query_add}

        logger.info("{}: {} - {}".format(es_type, time_from, time_to))
        for hit in self._fetch_elasticsearch(es_query):
            item = {}
            try:
                item['user'] = hit['_source'].get('id_user')
                if ip_users:
                    assert 0 == item['user']
                else:
                    assert 0 != item['user']
                assert es_type == hit['_type']

                item['timestamp'] = float(hit['_source']['@timestamp']) / 1000

                if ip_users:
                    item['ip'] = str(hit['_source'].get('client_host'))
                    user_agent = str(hit['_source'].get('user_agent'))
                    if user_agent is None or user_agent == 'None':
                        continue
                    elif _is_bot(user_agent):
                        continue
                    item['user_agent'] = user_agent
                item['recid'] = int(hit['_source'].get('id_bibrec'))

            except UnicodeEncodeError as e:
                # TODO: Error logging.
                # print(e)
                continue

            # Save entry
            store.add_hit(item)
        store.close()
        # Delete File if no hits were added.
        if store.number_of_hits == 0:
            store.delete()