[metrics-bugs] #24470 [Metrics/Analysis]: Distinguish point events from ongoing events in metrics timeline

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Jan 9 00:32:31 UTC 2018


#24470: Distinguish point events from ongoing events in metrics timeline
------------------------------+------------------------------
 Reporter:  dcf               |          Owner:  metrics-team
     Type:  enhancement       |         Status:  needs_review
 Priority:  Medium            |      Milestone:
Component:  Metrics/Analysis  |        Version:
 Severity:  Normal            |     Resolution:
 Keywords:  metrics-timeline  |  Actual Points:
Parent ID:                    |         Points:
 Reviewer:                    |        Sponsor:
------------------------------+------------------------------
Changes (by dcf):

 * status:  new => needs_review


Comment:

 In [[doc/MetricsTimeline?action=diff&version=215]] I went with Idea 2;
 that is, point events have a blank end date, and ongoing events have an
 end date of "ongoing".

 I initially intended to implement Idea 1 (mark the point events instead of
 the ongoing events). In fact I had it all implemented and then I changed
 my mind. The main reason was that almost all the entries, whose end date
 is blank, are point events and not ongoing events. I went through the
 whole timeline and only at most 10 were ongoing. One of the things we're
 going to have to do is periodically check which ongoing events have ended,
 and it's easier to ctrl-F for "ongoing" than it is to search for the
 absence of a mark. In fact some of the entries I marked "ongoing" I
 suspect have already ended. The "ongoing" marker therefore serves as a
 todo of sorts.

 The necessary code changes were, for me, pretty small. Here is the diff
 from the `tidy` script in metrics-timeline-tools:
 {{{
 #!diff
 @@ -28,20 +28,22 @@ class Entry(object):
      def __init__(self):
          self.start_date = None
          self.start_date_approx = None
          self.end_date = None
          self.end_date_approx = False
 +        self.is_ongoing = False
          self.places = set()
          self.protocols = set()
          self.description = None
          self.links = []

      @staticmethod
      def from_table_row(row):
          entry = Entry()
          entry.start_date, entry.start_date_approx =
 parse_datetime(row.start_date)
          entry.end_date, entry.end_date_approx =
 parse_datetime(row.end_date)
 +        entry.is_ongoing = row.end_date == "ongoing"
          entry.places = set(row.places.split())
          entry.protocols = set(row.protocols.split())
          entry.description = parse_wikitext(row.description)
          entry.links = parse_links(row.links)
          return entry
 @@ -57,20 +59,20 @@ class Entry(object):
          )

      def to_wikitext_row(self):
          cells = (
              format_datetime_approx(self.start_date,
 self.start_date_approx),
 -            format_datetime_approx(self.end_date, self.end_date_approx),
 +            self.is_ongoing and "ongoing" or
 format_datetime_approx(self.end_date, self.end_date_approx),
              " ".join(sorted(self.places)),
              " ".join(sorted(self.protocols)),
              self.description.to_wikitext(),
              " ".join(link.to_wikitext() for link in self.links),
          )
          return format_table_row(cells)

  def parse_datetime(s):
 -    if s == "":
 +    if s == "" or s == "ongoing":
          return None, False

      approx = False
      if s.startswith("~"):
          approx = True
 }}}

 And in my [https://people.torproject.org/~dcf/metrics-country.html
 metrics-country.html] page, I treat ongoing entries as having an infinite
 end date for the purpose of filtering, and treat them specially when
 formatting the date field:
 {{{
 #!diff
 @@ -6789,7 +6789,7 @@ function accept_entry(entry, start, end, country) {
                 return false;
         }
         if (entry.start_date && !entry.end_date && entry.start_date <
 start) {
 -               return false;
 +               return entry.is_ongoing;
         }
         if (entry.end_date && !entry.start_date && entry.end_date > end) {
                 return false;
 @@ -6891,7 +6891,11 @@ function format_timeline_entry_dates(entry) {
         if (entry.start_date && entry.end_date) {
                 return format_date(entry.start_date,
 entry.start_date_approx) + " – " + format_date(entry.end_date,
 entry.end_date_approx);
         } else if (entry.start_date) {
 -               return format_date(entry.start_date,
 entry.start_date_approx);
 +               if (entry.is_ongoing) {
 +                       return format_date(entry.start_date,
 entry.start_date_approx) + " – present";
 +               } else {
 +                       return format_date(entry.start_date,
 entry.start_date_approx);
 +               }
         } else if (entry.end_date) {
                 return "? – " + format_date(entry.end_date,
 entry.end_date_approx);
         } else {
 }}}

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24470#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the metrics-bugs mailing list