<commit_before>﻿@*
    Generates an iCalendar output for the UserID calendar given in the first URL segment
    if the token given in the second URL segment math the user private-calendar-token.
    The third parameter MUST be 'ical'
*@
@{
    var userID = UrlData[0].AsInt();
    var token = UrlData[1];
    var f = UrlData[2];

    if (f == "ical" && userID > 0) {
        using (var db = Database.Open("sqlloco")) {
            if (db.QueryValue("SELECT PrivateCalendarToken FROM CalendarProviderAttributes WHERE UserID=@0", userID)
                == token) {
                var file = LcCalendar.Export(userID);
                Response.ContentType = "text/calendar";
                Response.WriteBinary(file.Item1, "text/calendar");
            }
        }
    }
}<commit_msg>Added a logger to the Calendar Export page to guess the frequency of Google Calendar refreshing our calendars. Related to #228<commit_after>﻿@*
    Generates an iCalendar output for the UserID calendar given in the first URL segment
    if the token given in the second URL segment math the user private-calendar-token.
    The third parameter MUST be 'ical'
*@
@{
    var userID = UrlData[0].AsInt();
    var token = UrlData[1];
    var f = UrlData[2];

    if (f == "ical" && userID > 0) {
        using (var db = Database.Open("sqlloco")) {
            if (db.QueryValue("SELECT PrivateCalendarToken FROM CalendarProviderAttributes WHERE UserID=@0", userID)
                == token) {
                var file = LcCalendar.Export(userID);
                Response.ContentType = "text/calendar";
                Response.WriteBinary(file.Item1, "text/calendar");
            }
        }
        // Logger
        using (var logger = new LcLogger("calendar"))
        {
            logger.Log("Calendar public Export:");
            logger.Log("Request:: {0} {1}", Request.HttpMethod, Request.RawUrl);
            logger.Log("User-Agent:: {0}", Request.UserAgent);
            logger.Log("User-Address:: {0} {1}", Request.UserHostAddress, Request.UserHostName);
            logger.Save();
        }
    }
}
{'fraction_non_alphanumeric': 0.11567877629063097, 'fraction_numerical': 0.009560229445506692, 'mean_word_length': 2.3488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3264318', 'n_tokens_mistral': 601, 'n_tokens_neox': 576, 'n_words': 179}