<commit_before>from django.utils.translation import gettext_lazy as _

from oscar.core.loading import get_class, get_model

ReportGenerator = get_class('dashboard.reports.reports', 'ReportGenerator')
ReportCSVFormatter = get_class('dashboard.reports.reports',
                               'ReportCSVFormatter')
ReportHTMLFormatter = get_class('dashboard.reports.reports',
                                'ReportHTMLFormatter')
Basket = get_model('basket', 'Basket')


class OpenBasketReportCSVFormatter(ReportCSVFormatter):
    filename_template = 'open-baskets-%s-%s.csv'

    def generate_csv(self, response, baskets):
        writer = self.get_csv_writer(response)
        header_row = [_('User ID'),
                      _('Name'),
                      _('Email'),
                      _('Basket status'),
                      _('Num lines'),
                      _('Num items'),
                      _('Date of creation'),
                      _('Time since creation'),
                      ]
        writer.writerow(header_row)

        for basket in baskets:
            if basket.owner:
                row = [basket.owner_id, basket.owner.get_full_name(),
                       basket.owner.email,
                       basket.status, basket.num_lines,
                       self.format_datetime(basket.date_created),
                       basket.time_since_creation]
            else:
                row = [basket.owner_id, None, None, basket.status,
                       basket.num_lines, basket.num_items,
                       self.format_datetime(basket.date_created),<commit_msg>Add missing num_items column values in open basket CSV report generator (#3462)<commit_after>from django.utils.translation import gettext_lazy as _

from oscar.core.loading import get_class, get_model

ReportGenerator = get_class('dashboard.reports.reports', 'ReportGenerator')
ReportCSVFormatter = get_class('dashboard.reports.reports',
                               'ReportCSVFormatter')
ReportHTMLFormatter = get_class('dashboard.reports.reports',
                                'ReportHTMLFormatter')
Basket = get_model('basket', 'Basket')


class OpenBasketReportCSVFormatter(ReportCSVFormatter):
    filename_template = 'open-baskets-%s-%s.csv'

    def generate_csv(self, response, baskets):
        writer = self.get_csv_writer(response)
        header_row = [_('User ID'),
                      _('Name'),
                      _('Email'),
                      _('Basket status'),
                      _('Num lines'),
                      _('Num items'),
                      _('Date of creation'),
                      _('Time since creation'),
                      ]
        writer.writerow(header_row)

        for basket in baskets:
            if basket.owner:
                row = [basket.owner_id, basket.owner.get_full_name(),
                       basket.owner.email,
                       basket.status, basket.num_lines, basket.num_items,
                       self.format_datetime(basket.date_created),
                       basket.time_since_creation]
            else:
                row = [basket.owner_id, None, None, basket.status,
                       basket.num_lines, basket.num_items,
                       self.format_datetime(basket.date_created),
{'fraction_non_alphanumeric': 0.0964328899637243, 'fraction_numerical': 0.0012091898428053204, 'mean_word_length': 1.7483388704318936, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6697591', 'n_tokens_mistral': 875, 'n_tokens_neox': 823, 'n_words': 157}