changed last run datetime and next run datetime formater for rule from timestamp to strftime
parent
03d532871e
commit
669e299826
|
@ -21,7 +21,6 @@
|
|||
<th >{{'FDD.EXPRESSION' | translate}}</th>
|
||||
<th >{{'FDD.MESSAGE_TEMPLATE' | translate}}</th>
|
||||
<th >{{'SETTING.ACTION' | translate}}</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -33,14 +32,13 @@
|
|||
<td >{{ rule.priority }}</td>
|
||||
<td >{{ rule.channel }}</td>
|
||||
<td >{{ rule.is_enabled==true?'SETTING.ON':'SETTING.OFF' | translate}}</td>
|
||||
<td >{{ rule.last_run_datetime | date:'yyyy-MM-ddTHH:mm:ss'}}</td>
|
||||
<td >{{ rule.next_run_datetime | date:'yyyy-MM-ddTHH:mm:ss'}}</td>
|
||||
<td >{{ rule.last_run_datetime }}</td>
|
||||
<td >{{ rule.next_run_datetime }}</td>
|
||||
<td > {{'FDD.CLICK_EDIT_FOR_DETAILS' | translate}} </td>
|
||||
<td > {{'FDD.CLICK_EDIT_FOR_DETAILS' | translate}} </td>
|
||||
<td class="text-center">
|
||||
<a class="btn btn-primary btn-rounded btn-xs" ng-click="editRule(rule)" >{{'SETTING.EDIT' | translate}}</a>
|
||||
<a ng-click="deleteRule(rule)" class="btn btn-danger btn-rounded btn-xs" >{{'SETTING.DELETE' | translate}}</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -1247,8 +1247,8 @@ Result in JSON
|
|||
| expression | string | JSON string of diagnosed objects, points, values, and recipients |
|
||||
| message_template | string | Plain text template that supports $-substitutions |
|
||||
| is_enabled | boolean | Indicates if this rule is enabled |
|
||||
| last_run_datetime | float | null, or the number of milliseconds since January 1, 1970, 00:00:00, universal time |
|
||||
| next_run_datetime | float | null, or the number of milliseconds since January 1, 1970, 00:00:00, universal time |
|
||||
| last_run_datetime | float | null, or the last run datetime string in local timezone |
|
||||
| next_run_datetime | float | null, or the next run datetime string in local timezone |
|
||||
|
||||
```bash
|
||||
curl -i -X GET {{base_url}}/rules/{id}
|
||||
|
|
|
@ -2,7 +2,7 @@ import falcon
|
|||
import json
|
||||
import mysql.connector
|
||||
import uuid
|
||||
from datetime import timezone
|
||||
from datetime import datetime, timezone, timedelta
|
||||
import config
|
||||
from core.userlogger import user_logger
|
||||
|
||||
|
@ -33,16 +33,26 @@ class RuleCollection:
|
|||
cursor.close()
|
||||
cnx.disconnect()
|
||||
|
||||
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
||||
if config.utc_offset[0] == '-':
|
||||
timezone_offset = -timezone_offset
|
||||
|
||||
result = list()
|
||||
if rows is not None and len(rows) > 0:
|
||||
for row in rows:
|
||||
last_run_datetime = None
|
||||
if row['last_run_datetime_utc'] is not None:
|
||||
last_run_datetime = row['last_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
||||
if isinstance(row['last_run_datetime_utc'], datetime):
|
||||
last_run_datetime_local = row['last_run_datetime_utc'].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
last_run_datetime = last_run_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
else:
|
||||
last_run_datetime = None
|
||||
|
||||
next_run_datetime = None
|
||||
if row['next_run_datetime_utc'] is not None:
|
||||
next_run_datetime = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
||||
if isinstance(row['next_run_datetime_utc'], datetime):
|
||||
next_run_datetime_local = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
next_run_datetime = next_run_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
else:
|
||||
next_run_datetime = None
|
||||
|
||||
meta_result = {"id": row['id'], "name": row['name'], "uuid": row['uuid'],
|
||||
"category": row['category'], "fdd_code": row['fdd_code'], "priority": row['priority'],
|
||||
|
@ -204,13 +214,23 @@ class RuleItem:
|
|||
if row is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
||||
description='API.RULE_NOT_FOUND')
|
||||
last_run_datetime = None
|
||||
if row['last_run_datetime_utc'] is not None:
|
||||
last_run_datetime = row['last_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
||||
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
||||
if config.utc_offset[0] == '-':
|
||||
timezone_offset = -timezone_offset
|
||||
|
||||
next_run_datetime = None
|
||||
if row['next_run_datetime_utc'] is not None:
|
||||
next_run_datetime = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
|
||||
if isinstance(row['last_run_datetime_utc'], datetime):
|
||||
last_run_datetime_local = row['last_run_datetime_utc'].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
last_run_datetime = last_run_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
else:
|
||||
last_run_datetime = None
|
||||
|
||||
if isinstance(row['next_run_datetime_utc'], datetime):
|
||||
next_run_datetime_local = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc) + \
|
||||
timedelta(minutes=timezone_offset)
|
||||
next_run_datetime = next_run_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
else:
|
||||
next_run_datetime = None
|
||||
|
||||
result = {"id": row['id'], "name": row['name'], "uuid": row['uuid'],
|
||||
"category": row['category'], "fdd_code": row['fdd_code'], "priority": row['priority'],
|
||||
|
|
Loading…
Reference in New Issue