dustin / bindir

My ~/bin
Other
138 stars 21 forks source link

Working hours #5

Open stephanenicolas opened 11 years ago

stephanenicolas commented 11 years ago

Thank you very much Dustin. You really made my day today. You scripts are damn useful to me.

Do you think it would be possible to have a script printing the number of work hours inside a given range of time to compute extra working hours at the job ?

dustin commented 11 years ago

It's really hard to estimate. You only see when things were finished, no idea when they were started.

Dustin Sallings

stephanenicolas notifications@github.com wrote:

Thank you very much Dustin. You really made my day today. You scripts are damn useful to me.

Do you think it would be possible to have a script printing the number of work hours inside a given range of time to compute extra working hours at the job ?

— Reply to this email directly or view it on GitHub.

stephanenicolas commented 11 years ago

I agree with you. We will never able to say that.

Nevertheless, git users get more and more used to do small commits when they get trained. And such stats could turn out to be accurate enough. Anyhow, it would be much much better than nothing.

Who doesn't over work in IT ?

S. Le 25 mai 2013 21:55, "Dustin Sallings" notifications@github.com a écrit :

It's really hard to estimate. You only see when things were finished, no idea when they were started.

Dustin Sallings

stephanenicolas notifications@github.com wrote:

Thank you very much Dustin. You really made my day today. You scripts are damn useful to me.

Do you think it would be possible to have a script printing the number of work hours inside a given range of time to compute extra working hours at the job ?

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/dustin/bindir/issues/5#issuecomment-18452952 .

stephanenicolas commented 11 years ago

Do you think it would be possible to publish something, even quick and dirty, so that I can get an estimate of hours of commits inside the range "Monday to Friday, from 9 to 18" for instance ? I would like to visualize both

I would love to contribute to your repo, but I am a pure java programmer and I am not confortable at all with python. If you could issue something (ideally today or within a few days) it would really help.

Stéphane

dustin commented 11 years ago

I'm just not sure what you're asking for is possible. The timecard thing will tell you when work was done, but not tell you how long the work took. The information just isn't there.

stephanenicolas wrote:

Do you think it would be possible to publish something, even quick and dirty, so that I can get an estimate of hours of commits inside the range "Monday to Friday, from 9 to 18" for instance ? I would like to visualize both

  • total hours inside the range
  • total hours outside the range
  • pie chart showing the ranges ratio above (with respect to total hours)

I would love to contribute to your repo, but I am a pure java programmer and I am not confortable at all with python. If you could issue something (ideally today or within a few days) it would really help.

Stéphane

— Reply to this email directly or view it on GitHub https://github.com/dustin/bindir/issues/5#issuecomment-18483987.

stephanenicolas commented 11 years ago

Hi Justin,

again, I agree with you. But, still, as this is the only data we have, it's better than nothing. And if commits are tiny enough then data becomes accurate. Maybe, I should rephrase my feature request : 'I would like to know how much I commited code outside of working hours and inside working hours'. And, we have this data.

Stéphane

2013/5/27 Dustin Sallings notifications@github.com

I'm just not sure what you're asking for is possible. The timecard thing will tell you when work was done, but not tell you how long the work took. The information just isn't there.

stephanenicolas wrote:

Do you think it would be possible to publish something, even quick and dirty, so that I can get an estimate of hours of commits inside the range "Monday to Friday, from 9 to 18" for instance ? I would like to visualize both

  • total hours inside the range
  • total hours outside the range
  • pie chart showing the ranges ratio above (with respect to total hours)

I would love to contribute to your repo, but I am a pure java programmer and I am not confortable at all with python. If you could issue something (ideally today or within a few days) it would really help.

Stéphane

— Reply to this email directly or view it on GitHub https://github.com/dustin/bindir/issues/5#issuecomment-18483987.

— Reply to this email directly or view it on GitHubhttps://github.com/dustin/bindir/issues/5#issuecomment-18484282 .

Stéphane NICOLAS, OCTO Technology Développeur & Consultant Android / Java .......................................................... 50, Avenue des Champs-Elysées 75008 Paris +33 (0)6.26.32.34.09 www.octo.com - blog.octo.com www.usievents.com ...........................................................

stephanenicolas commented 11 years ago

That would be more or less the equivalent of this bash script :

echo "AUTHOR: $1"

W=`for DAY in Mon Tue Wed Thu Fri
do 
   for HOUR in 09 10 11 12 13 14 15 16 17 18
   do 
     git log --pretty=format:"%ad" --author '$1' | grep "$DAY .* $HOUR:" | awk -F ":" '{print $1}'
   done
done | sort | uniq | wc -l`

echo "Working hours: $W"

T=`git log --pretty=format:"%ad" --author '$1' | grep "$DAY .* $HOUR:" | awk -F ":" '{print $2}' | sort | uniq | wc -l`
echo "All hours: $T" 

R=`echo "scale=2; 100*$W/$T" | bc`
echo "Ratio of working hours $R %"

R=`echo "scale=2; 100-(100*$W/$T)" | bc`
echo "Ratio of non working hours $R %"
stephanenicolas commented 11 years ago

Here is the python script to get a pie chart. If you add it to gitaggregates.py, I would be proud of this first contribution. Python can be really funny I think. The result needs some polish for sure, like a title and a legend, but that's enough for me.

class WorkingHours(object):

    WORKING_HOUR = 0
    EXTRA_HOUR = 1
    width = 420
    height = 300
    max_entries = 2

    def __init__(self):
        self.h = defaultdict(lambda: 0)

    def add_logs(self, directory=None, log_args=['HEAD']):
        args=['git']
        if directory:
            args.append('--git-dir=' + directory)
        args.extend(['log', '--format=%ad', '--date=raw'])
        args.extend(log_args)
        sub = subprocess.Popen(args, stdout=subprocess.PIPE, close_fds=True)

        for l in sub.stdout:
            t, offset = l.strip().split(' ')
            t = float(t) + int(offset) / 100 * 3600

            hour = int(time.strftime("%H", time.gmtime(t)))
            if( hour > 9 and hour < 18 ) :
                self.h[self.WORKING_HOUR] += 1
            else :
                self.h[self.EXTRA_HOUR] += 1

    def mk_chart(self):
        from pygooglechart import PieChart2D
        chart = PieChart2D(self.width, self.height)

        chart.add_data([self.h[0], self.h[1]])
        sys.stderr.write(repr(self.h) + "\n")

        chart.set_pie_labels("WorkingHours ExtraHours".split(" "))

        return chart

    def to_gchart(self):
        return self.mk_chart().get_url()

def open_chart(chartish):
    subprocess.check_call(['open', chartish.to_gchart()])

Thanks for your work, it is really nice.

Stéphane