equal
deleted
inserted
replaced
40 skip = (page - 1) * count |
40 skip = (page - 1) * count |
41 |
41 |
42 else : |
42 else : |
43 skip = None |
43 skip = None |
44 |
44 |
|
45 # go through the logs a page at a time |
|
46 this_page = 1 |
|
47 |
|
48 # last line's timestamp |
|
49 last_ts = None |
|
50 |
|
51 # found it yet? |
|
52 found = False |
|
53 |
45 # count the full number of lines |
54 # count the full number of lines |
46 line_count = 0 |
55 line_count = 0 |
47 |
56 |
48 # collect lines |
57 # collect lines |
49 lines = [] |
58 lines = [] |
55 |
64 |
56 # skip? |
65 # skip? |
57 if skip : |
66 if skip : |
58 skip -= 1 |
67 skip -= 1 |
59 continue |
68 continue |
60 |
69 |
61 # already full? |
70 # is this page all that we want/need? |
62 if len(lines) > count : |
71 if page or found : |
63 continue |
72 # already full? |
64 |
73 if len(lines) >= count : |
|
74 continue |
|
75 |
|
76 # specfic timestamp |
|
77 else : |
|
78 # didn't find it in this page? |
|
79 if len(lines) >= count : |
|
80 # reset to next page |
|
81 lines = [] |
|
82 this_page += 1 |
|
83 |
|
84 # is dt between these two timestamps? |
|
85 if (not last_ts or last_ts <= dt) and (dt <= line.timestamp) : |
|
86 # found! |
|
87 found = True |
|
88 page = this_page |
|
89 |
|
90 else : |
|
91 # keep looking |
|
92 last_ts = line.timestamp |
|
93 |
65 # store line |
94 # store line |
66 lines.append(line) |
95 lines.append(line) |
67 |
96 |
68 # calculate max_pages |
97 # calculate max_pages |
69 max_pages = math.ceil(float(line_count) / count) |
98 max_pages = math.ceil(float(line_count) / count) |