예제 #1
0
def _write_bookings_by_type_and_digital_counts(departement_code: str,
                                               worksheet: Worksheet,
                                               current_row: int):
    if departement_code:
        bookings_by_type_and_digital_counts = get_offer_counts_grouped_by_type_and_medium(
            partial(
                query_get_booking_counts_grouped_by_type_and_medium_for_departement,
                departement_code=departement_code), 'Nombre de réservations')
    else:
        bookings_by_type_and_digital_counts = get_offer_counts_grouped_by_type_and_medium(
            query_get_booking_counts_grouped_by_type_and_medium,
            'Nombre de réservations')
    worksheet.set_dataframe(bookings_by_type_and_digital_counts,
                            f'E{current_row}')
예제 #2
0
def _write_offer_counts_grouped_by_type_and_medium(departement_code: str,
                                                   worksheet: Worksheet,
                                                   current_row: int):
    if departement_code:
        offer_counts_grouped_by_type_and_medium = get_offer_counts_grouped_by_type_and_medium(
            partial(
                query_get_offer_counts_grouped_by_type_and_medium_for_departement,
                departement_code=departement_code), 'Nombre d\'offres')
    else:
        offer_counts_grouped_by_type_and_medium = get_offer_counts_grouped_by_type_and_medium(
            query_get_offer_counts_grouped_by_type_and_medium,
            'Nombre d\'offres')
    worksheet.set_dataframe(offer_counts_grouped_by_type_and_medium,
                            f'A{current_row}')
예제 #3
0
def add_comment_to_sheet(comment: praw.reddit.models.Comment,
                         worksheet: pyg.Worksheet):
    worksheet_df = worksheet.get_as_df()
    formatted_utc = datetime.utcfromtimestamp(comment.created_utc)
    new_entry = {
        'Point ID': worksheet_df['Point ID'].max() + 1,
        'Username': rf'/u/{comment.parent().author}',
        'Comment Link':
        rf'https://old.reddit.com/comments/{comment.link_id[3:]}/_/{comment.id}/?context=3',
        'Subreddit': rf"/r/{comment.subreddit}",
        'Date': formatted_utc.strftime('%Y-%m-%d  %H:%M:%S'),
        'Comment ID': comment.id
    }

    worksheet_df = pd.concat(
        [worksheet_df, pd.DataFrame(new_entry, index=[1])])
    worksheet.set_dataframe(worksheet_df, start='A1')