コード例 #1
0
    def post(self):
        try:
            json_data = request.get_json(force=True)
            issue = json_data['issue']
            start_time = json_data['start_time']
            end_time = json_data['end_time']
            username = json_data['username']
            # data = {}
            # data['info'] = {'issue': issue, 'start_time': start_time,
            # 'end_time': end_time, 'username': username}
            shared.set_issue_number(issue)
            tz = metadata.get_tz_info()
            start_time = metadata.convert_from_js(start_time, tz)
            end_time = metadata.convert_from_js(end_time, tz)
            start_time += ':00' + tz
            end_time += ':00' + tz
            issuenumber = shared.get_issue_number()

            note_dict = {}
            note_dict = {
                'user': shared.get_git_variables()['username'],
                'timestamp_start': start_time,
                'timestamp_end': end_time,
                'issue': issuenumber
            }
            gtc.store(target=[
                shared.get_git_variables()['username'],
                datetime.now().year,
                datetime.now().month
            ],
                      content=note_dict)
            newdata = {}
            newdata['split_days'] = metadata.split_on_days(
                gtc.get_all_by_path([
                    shared.get_git_variables()['username'],
                    datetime.now().year,
                    datetime.now().month
                ]))
            return jsonify(status="Succes", newdata=newdata)
        except:
            print('CRASH!')
            newdata['split_days'] = metadata.split_on_days(
                gtc.get_all_by_path([
                    shared.get_git_variables()['username'],
                    datetime.now().year,
                    datetime.now().month
                ]))
            return jsonify(status="Failed", data=newdata)
コード例 #2
0
 def get(self):
     newdata = {}
     newdata['split_days'] = metadata.split_on_days(
         gtc.get_all_by_path([
             shared.get_git_variables()['username'],
             datetime.now().year,
             datetime.now().month
         ]))
     return jsonify(newdata=newdata)
コード例 #3
0
ファイル: visualconsole.py プロジェクト: prolike/timereg
def main():
    username = shared.get_git_variables()['username']
    url = shared.get_git_variables()['url']
    split_days = metadata.split_on_days(gtc.get_all_as_dict())
    t_string = '\n'
    t_string += (username + ' worked on project ' + url.split('/')[4])
    t_string += ('\nurl: ' + url + '\n')
    t_string += table_print(split_days)
    print(t_string)
コード例 #4
0
 def post(self):
     json_data = request.get_json(force=True)
     sha1 = json_data['sha1']
     gtc.store(target=[
         shared.get_git_variables()['username'],
         datetime.now().year,
         datetime.now().month
     ],
               remove=sha1)
     newdata = {}
     newdata['split_days'] = metadata.split_on_days(
         gtc.get_all_by_path([
             shared.get_git_variables()['username'],
             datetime.now().year,
             datetime.now().month
         ]))
     return jsonify(newdata=newdata)
コード例 #5
0
ファイル: metadata.py プロジェクト: prolike/timereg
 def test_split_on_days(self):
     data = [{
         '0b1db79bc5bee19082e3df454f6d3748d6d831e1': {
             'issue': 7,
             'timestamp_end': '2018-11-29T13:50:00+0100',
             'timestamp_start': '2018-11-29T13:50:00+0100',
             'user': '******'
         },
         '0e321dc8650bd0ee5f8b42cbd1c8dc6c2d2c2ca4': {
             'issue': 888,
             'timestamp_start': '2018-11-30T08:49:00+0100',
             'user': '******'
         }
     }]
     ans = defaultdict(list)
     ans['2018-11-29'].append({
         'issue':
         7,
         'timestamp_end':
         '2018-11-29T13:50:00+0100',
         'timestamp_start':
         '2018-11-29T13:50:00+0100',
         'user':
         '******',
         'sha1':
         '0b1db79bc5bee19082e3df454f6d3748d6d831e1'
     })
     ans['2018-11-30'].append({
         'issue':
         888,
         'timestamp_start':
         '2018-11-30T08:49:00+0100',
         'user':
         '******',
         'sha1':
         '0e321dc8650bd0ee5f8b42cbd1c8dc6c2d2c2ca4'
     })
     self.assertEqual(metadata.split_on_days(data), ans)
コード例 #6
0
    def put(self):
        try:
            json_data = request.get_json(force=True)
            sha1 = json_data['sha1']
            newissue = json_data['issue']
            timestamp_start = json_data['start_time']
            timestamp_end = json_data['end_time']
            tz = metadata.get_tz_info()
            og = gtc.get_all_by_path([
                shared.get_git_variables()['username'],
                datetime.now().year,
                datetime.now().month
            ])[sha1]
            try:
                issue = og['issue']
            except:
                issue = None
            try:
                if int(issue) != int(newissue):
                    issue = newissue
            except:
                issue = newissue
            timestamp_start = metadata.convert_from_js(timestamp_start, tz)
            timestamp_end = metadata.convert_from_js(timestamp_end, tz)
            if datetime.strptime(timestamp_start,
                                 '%Y-%m-%dT%H:%M') <= datetime.strptime(
                                     timestamp_end, '%Y-%m-%dT%H:%M'):
                time = timestamp_start[11:]
                datestamp = timestamp_start[:10]
                month = datestamp[5:-3]
                date = datestamp[-2:]
                hour = time[:2]
                minute = time[-2:]
                timestamp_start = metadata.time(chour=hour,
                                                cminute=minute,
                                                cday=date,
                                                cmonth=month)
                time = timestamp_end[11:]
                datestamp = timestamp_end[:10]
                month = datestamp[5:-3]
                date = datestamp[-2:]
                hour = time[:2]
                minute = time[-2:]
                timestamp_end = metadata.time(chour=hour,
                                              cminute=minute,
                                              cday=date,
                                              cmonth=month)

            gtc.store(target=[
                shared.get_git_variables()['username'],
                datetime.now().year,
                datetime.now().month
            ],
                      remove=sha1,
                      content={
                          'timestamp_end': timestamp_end,
                          'timestamp_start': timestamp_start,
                          'issue': issue,
                          'user': shared.get_git_variables()['username']
                      })

            newdata = {}
            newdata['split_days'] = metadata.split_on_days(
                gtc.get_all_by_path([
                    shared.get_git_variables()['username'],
                    datetime.now().year,
                    datetime.now().month
                ]))
            return jsonify(status="Succes", newdata=newdata)
        except:
            print('CRASH!')
            newdata = {}
            newdata['split_days'] = metadata.split_on_days(
                gtc.get_all_by_path([
                    shared.get_git_variables()['username'],
                    datetime.now().year,
                    datetime.now().month
                ]))
            return jsonify(status="Failed", data=newdata)