~thekorn/+junk/zg_aggregate_api

« back to all changes in this revision

Viewing changes to Aggregate API

  • Committer: Markus Korn
  • Date: 2010-11-25 16:24:01 UTC
  • Revision ID: thekorn@gmx.de-20101125162401-8j8gf8b1j7pu3awe
v1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Aggregate API
 
2
=============
 
3
 
 
4
I propose two new methods, FindEventIdsData and FindEventsData and a set
 
5
of new symbols/enums called AggregateMethod as described below.
 
6
 
 
7
Notes:
 
8
    * everything is a mixture of python and pseudo code
 
9
    
 
10
 
 
11
Methods
 
12
=======
 
13
    FindEventIdsData(
 
14
        time_range,
 
15
        event_templates, 
 
16
        storage_state,
 
17
        num_events,
 
18
        result_type,
 
19
        aggregate_method,
 
20
    ) --> (auau) "tuple of two lists of equal length containing integers"
 
21
 
 
22
    FindEventsData(
 
23
        time_range,
 
24
        event_templates, 
 
25
        storage_state,
 
26
        num_events,
 
27
        result_type,
 
28
        aggregate_method,
 
29
    ) --> (aEau) "same as above, but in the first list the ids are replaced by the actual events"
 
30
    
 
31
Enums
 
32
=====
 
33
 
 
34
    AggregateMethod.
 
35
        Sum
 
36
        Count
 
37
        Max
 
38
        Min
 
39
        Average
 
40
        
 
41
 
 
42
Examples
 
43
========
 
44
 
 
45
* track was played maximum on Banshee
 
46
 
 
47
    >>> ids = FindEventIds(
 
48
    ...    TimeRange.always(),
 
49
    ...    [Event.new_for_values(actor="banshee", subject_interpretation=Interpretation.MUSIC),],
 
50
    ...    StorageState.Any,
 
51
    ...    2,
 
52
    ...    ResultType.MostPopularSubjects
 
53
    ...)
 
54
    >>> print ids
 
55
    [1, 2]
 
56
    
 
57
    Which means, the subject of event 1 is most popular, followed by
 
58
    event 2.
 
59
    But we currently don't know *how* popular they are.
 
60
    
 
61
    >>> ids, data = FindEventIDsData(
 
62
    ...    TimeRange.always(),
 
63
    ...    [Event.new_for_values(actor="banshee", subject_interpretation=Interpretation.MUSIC),],
 
64
    ...    StorageState.Any,
 
65
    ...    2,
 
66
    ...    ResultType.MostPopularSubjects,
 
67
    ...    AggregateMethod.Count
 
68
    ... )
 
69
    >>> print ids
 
70
    [1, 2]
 
71
    >>> print data
 
72
    [500, 250]
 
73
    
 
74
    So, ids is the same as above; data contains the `count` for each
 
75
    subject. So the subject represented by event 1 was played 500 times,
 
76
    followed by the subject represented by event 2 with 250 times.
 
77
 
 
78
* average number of plays from each player
 
79
 
 
80