<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13648] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13648">13648</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-06-17 12:13:35 -0700 (Tue, 17 Jun 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add additional auto-accept logging. Fix calverify timezone issue.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarservertoolscalverifypy">CalendarServer/trunk/calendarserver/tools/calverify.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavaccountingpy">CalendarServer/trunk/twistedcaldav/accounting.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingfreebusypy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarservertoolscalverifypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/calverify.py (13647 => 13648)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/calverify.py        2014-06-17 18:18:04 UTC (rev 13647)
+++ CalendarServer/trunk/calendarserver/tools/calverify.py        2014-06-17 19:13:35 UTC (rev 13648)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">     InvalidICalendarDataError, Property, PERUSER_COMPONENT
</span><span class="cx"> )
</span><span class="cx"> from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
</span><ins>+from twistedcaldav.timezones import TimezoneCache
</ins><span class="cx"> from txdav.caldav.datastore.scheduling.icalsplitter import iCalSplitter
</span><span class="cx"> from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
</span><span class="cx"> from txdav.caldav.datastore.scheduling.itip import iTipGenerator
</span><span class="lines">@@ -205,7 +206,7 @@
</span><span class="cx"> if not hasattr(Component, &quot;maxAlarmCounts&quot;):
</span><span class="cx">     Component.hasDuplicateAlarms = new_hasDuplicateAlarms
</span><span class="cx"> 
</span><del>-VERSION = &quot;11&quot;
</del><ins>+VERSION = &quot;12&quot;
</ins><span class="cx"> 
</span><span class="cx"> def printusage(e=None):
</span><span class="cx">     if e:
</span><span class="lines">@@ -305,6 +306,8 @@
</span><span class="cx"> 
</span><span class="cx"> v11: Allows manual splitting of recurring events.
</span><span class="cx"> 
</span><ins>+v12: Fix double-booking false positives caused by timezones-by-reference.
+
</ins><span class="cx"> &quot;&quot;&quot; % (VERSION,)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -401,7 +404,9 @@
</span><span class="cx">         self.totalErrors = None
</span><span class="cx">         self.totalExceptions = None
</span><span class="cx"> 
</span><ins>+        TimezoneCache.create()
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     def title(self):
</span><span class="cx">         return &quot;&quot;
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavaccountingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/accounting.py (13647 => 13648)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/accounting.py        2014-06-17 18:18:04 UTC (rev 13647)
+++ CalendarServer/trunk/twistedcaldav/accounting.py        2014-06-17 19:13:35 UTC (rev 13648)
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">     if &quot;*&quot; in enabledRecordGUIDs:
</span><span class="cx">         return True
</span><span class="cx"> 
</span><del>-    return record.guid in enabledRecordGUIDs
</del><ins>+    return record.uid in enabledRecordGUIDs
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -84,9 +84,9 @@
</span><span class="cx">         principalLogPath = record
</span><span class="cx">     elif accountingEnabled(category, record):
</span><span class="cx">         principalLogPath = os.path.join(
</span><del>-            record.guid[0:2],
-            record.guid[2:4],
-            record.guid
</del><ins>+            record.uid[0:2],
+            record.uid[2:4],
+            record.uid
</ins><span class="cx">         )
</span><span class="cx">     else:
</span><span class="cx">         return None
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingfreebusypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py (13647 => 13648)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py        2014-06-17 18:18:04 UTC (rev 13647)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/freebusy.py        2014-06-17 19:13:35 UTC (rev 13648)
</span><span class="lines">@@ -107,6 +107,7 @@
</span><span class="cx">     servertoserver=False,
</span><span class="cx">     event_details=None,
</span><span class="cx">     logItems=None,
</span><ins>+    accountingItems=None,
</ins><span class="cx"> ):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Get freebusy information for a calendar. Different behavior for internal vs external calendars.
</span><span class="lines">@@ -128,7 +129,8 @@
</span><span class="cx">             same_calendar_user,
</span><span class="cx">             servertoserver,
</span><span class="cx">             event_details,
</span><del>-            logItems
</del><ins>+            logItems,
+            accountingItems,
</ins><span class="cx">         )
</span><span class="cx">     else:
</span><span class="cx">         return _internalGenerateFreeBusyInfo(
</span><span class="lines">@@ -142,7 +144,8 @@
</span><span class="cx">             same_calendar_user,
</span><span class="cx">             servertoserver,
</span><span class="cx">             event_details,
</span><del>-            logItems
</del><ins>+            logItems,
+            accountingItems,
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -160,6 +163,7 @@
</span><span class="cx">     servertoserver=False,
</span><span class="cx">     event_details=None,
</span><span class="cx">     logItems=None,
</span><ins>+    accountingItems=None,
</ins><span class="cx"> ):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Generate a freebusy response for an external (cross-pod) calendar by making a cross-pod call. This will bypass
</span><span class="lines">@@ -187,6 +191,7 @@
</span><span class="cx">     servertoserver=False,
</span><span class="cx">     event_details=None,
</span><span class="cx">     logItems=None,
</span><ins>+    accountingItems=None,
</ins><span class="cx"> ):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Run a free busy report on the specified calendar collection
</span><span class="lines">@@ -207,6 +212,7 @@
</span><span class="cx">         remote lookup request.
</span><span class="cx">     @param event_details: a C{list} into which to store extended VEVENT details if not C{None}
</span><span class="cx">     @param logItems: a C{dict} to store logging info to
</span><ins>+    @param accountingItems: a C{dict} to store accounting info to
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">     # First check the privilege on this collection
</span><span class="lines">@@ -262,6 +268,9 @@
</span><span class="cx"> 
</span><span class="cx">     if resources is None:
</span><span class="cx"> 
</span><ins>+        if accountingItems is not None:
+            accountingItems[&quot;fb-uncached&quot;] = accountingItems.get(&quot;fb-uncached&quot;, 0) + 1
+
</ins><span class="cx">         caching = False
</span><span class="cx">         if config.EnableFreeBusyCache:
</span><span class="cx">             # Log extended item
</span><span class="lines">@@ -295,6 +304,9 @@
</span><span class="cx">         )
</span><span class="cx">         filter = Filter(filter)
</span><span class="cx">         tzinfo = filter.settimezone(tz)
</span><ins>+        if accountingItems is not None:
+            tr = cache_timerange if caching else timerange
+            accountingItems[&quot;fb-query-timerange&quot;] = (str(tr.start), str(tr.end),)
</ins><span class="cx"> 
</span><span class="cx">         try:
</span><span class="cx">             resources = yield calresource.search(filter, useruid=attendee_uid, fbtype=True)
</span><span class="lines">@@ -304,6 +316,9 @@
</span><span class="cx">             raise InternalDataStoreError(&quot;Invalid indexedSearch query&quot;)
</span><span class="cx"> 
</span><span class="cx">     else:
</span><ins>+        if accountingItems is not None:
+            accountingItems[&quot;fb-cached&quot;] = accountingItems.get(&quot;fb-cached&quot;, 0) + 1
+
</ins><span class="cx">         # Log extended item
</span><span class="cx">         if logItems is not None:
</span><span class="cx">             logItems[&quot;fb-cached&quot;] = logItems.get(&quot;fb-cached&quot;, 0) + 1
</span><span class="lines">@@ -318,6 +333,29 @@
</span><span class="cx">             fbtype = 'F'
</span><span class="cx">         aggregated_resources.setdefault((name, uid, type, test_organizer,), []).append((float, start, end, fbtype,))
</span><span class="cx"> 
</span><ins>+    if accountingItems is not None:
+        accountingItems[&quot;fb-resources&quot;] = {}
+        for k, v in aggregated_resources.items():
+            name, uid, type, test_organizer = k
+            accountingItems[&quot;fb-resources&quot;][uid] = []
+            for float, start, end, fbtype in v:
+                fbstart = parseSQLTimestampToPyCalendar(start)
+                if float == 'Y':
+                    fbstart.setTimezone(tzinfo)
+                else:
+                    fbstart.setTimezone(Timezone(utc=True))
+                fbend = parseSQLTimestampToPyCalendar(end)
+                if float == 'Y':
+                    fbend.setTimezone(tzinfo)
+                else:
+                    fbend.setTimezone(Timezone(utc=True))
+                accountingItems[&quot;fb-resources&quot;][uid].append((
+                    float,
+                    str(fbstart),
+                    str(fbend),
+                    fbtype,
+                ))
+
</ins><span class="cx">     for key in aggregated_resources.iterkeys():
</span><span class="cx"> 
</span><span class="cx">         name, uid, type, test_organizer = key
</span><span class="lines">@@ -407,7 +445,13 @@
</span><span class="cx">                     elif (test_organizer is None) and same_calendar_user:
</span><span class="cx">                         continue
</span><span class="cx"> 
</span><ins>+            if accountingItems is not None:
+                accountingItems.setdefault(&quot;fb-filter-match&quot;, []).append(uid)
+
</ins><span class="cx">             if filter.match(calendar, None):
</span><ins>+                if accountingItems is not None:
+                    accountingItems.setdefault(&quot;fb-filter-matched&quot;, []).append(uid)
+
</ins><span class="cx">                 # Check size of results is within limit
</span><span class="cx">                 matchtotal += 1
</span><span class="cx">                 if matchtotal &gt; config.MaxQueryWithDataResults:
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py (13647 => 13648)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2014-06-17 18:18:04 UTC (rev 13647)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2014-06-17 19:13:35 UTC (rev 13648)
</span><span class="lines">@@ -649,7 +649,7 @@
</span><span class="cx">         if accountingEnabled(&quot;AutoScheduling&quot;, self.recipient.record):
</span><span class="cx">             accounting = {
</span><span class="cx">                 &quot;when&quot;: DateTime.getNowUTC().getText(),
</span><del>-                &quot;automode&quot;: automode,
</del><ins>+                &quot;automode&quot;: automode.name,
</ins><span class="cx">                 &quot;changed&quot;: False,
</span><span class="cx">             }
</span><span class="cx">         else:
</span><span class="lines">@@ -754,7 +754,7 @@
</span><span class="cx">                             end=str(makeTimedUTC(instance.end)),
</span><span class="cx">                         )
</span><span class="cx"> 
</span><del>-                        yield generateFreeBusyInfo(testcal, fbinfo, tr, 0, uid, servertoserver=True)
</del><ins>+                        yield generateFreeBusyInfo(testcal, fbinfo, tr, 0, uid, servertoserver=True, accountingItems=accounting if len(instances) == 1 else None)
</ins><span class="cx"> 
</span><span class="cx">                         # If any fbinfo entries exist we have an overlap
</span><span class="cx">                         if len(fbinfo[0]) or len(fbinfo[1]) or len(fbinfo[2]):
</span></span></pre>
</div>
</div>

</body>
</html>