source: stamper/bin/stamps@ 30:b8003f616519

Last change on this file since 30:b8003f616519 was 30:b8003f616519, checked in by Borja Lopez <borja@…>, 10 years ago

Refactored the graphs/charts code:

  • Fixed a bug introduced when we added the date-based filtering
  • Moved the graph/chart code into a separate method, calling only that method when the user wants to generate a graph.
  • Integrated the code a bit better with the new details method.
  • The svg files are generated using the current date and time, adding a -latest.svg symlink so finding the latest one is easier.

Some examples:

  • generate a chart of all the times recorded for all customers:

stamps -g

  • generates a chart of all the times recorded for all customers for the past week:

stamps -g 1w

  • generates a chart of all the times for a given customer since the first day of 2014:

stamps -g customer 2014-01-01*

(see the filters code to learn more about them)

Still some work needed here though, and I've disabled the nice stacking
bars, which should be back with some form of chart types selector
(so users can set on runtime which type of chart they want)

  • Property exe set to *
File size: 1.5 KB
Line 
1#!/usr/bin/env python
2
3import argparse
4from stamper import Stamper
5
6
7if __name__ == '__main__':
8
9 parser = argparse.ArgumentParser(
10 description='stamps: show recorded times information')
11 parser.add_argument('customer', action="store", nargs='?',
12 help='Show times only for this customer')
13 parser.add_argument('filter', action="store", nargs='?',
14 help='Filter the times by date range')
15 parser.add_argument('-v', '--verbose', action="store_true",
16 help='Include detailed times information')
17 parser.add_argument('-s', '--sum', action="store_true",
18 help='Include sum of times')
19 parser.add_argument('-g', '--graph', action="store_true",
20 help='Generate a SVG graph')
21 parser.add_argument('-t', '--timeline', action="store_true",
22 help='Show a timeline of recorded times')
23
24 args = parser.parse_args()
25
26 s = Stamper()
27 s.load_stamps()
28
29 # Set proper arguments if they have passed a date-based filter without
30 # a customer
31 if args.customer not in s.customers and not args.filter:
32 args.filter = args.customer
33 args.customer = None
34
35 # Call the proper methods, based on the given parameters
36 if args.timeline:
37 s.timeline()
38 elif args.graph:
39 s.graph_stamps(args.customer, args.filter)
40 else:
41 s.show_stamps(args.customer, args.filter, args.verbose, args.sum)
Note: See TracBrowser for help on using the repository browser.