在FullCalendar中显示了一些事件,但其他事件未显示

时间:2019-10-03 16:26:19

标签: javascript python fullcalendar fullcalendar-4

尝试在FullCalendar上显示事件时遇到问题。显示某些事件,而其他则不显示。

我通过JSON填写了功能表,到目前为止,即使分页只检索所选月份的事件,也可以正常工作。

...
events: {
    url: '/getEvents',
    method: 'GET',
    failure: function(error) {
        console.log(error);
        alerta("Error", "Ups...", "red");
    },
},
...

但是现在我试图从存储在数据库中的其他东西中添加更多事件,尽管以相同的方式构造了它们,但它们并未显示在日历上。

我这样构造事件(我已经清理了代码):

rows = connection.execute("SELECT...........")
events = []
for row in rows:
    event = {"id": row['id'], "title": row['title'], "start": row['start'], "end": row['end'], "allDay": row['allDay'], "url": row['url'], "color": row['color'], "extendedProps": {"company": row['company'], "state": fila['state']}}
    if row['groupId'] is not None:
        event['groupId'] = str(row['groupId'])
   events.append(event)

现在,在程序的其他部分,我以类似的方式创建事件:

more_rows = connection.execute("SELECT....")
more_events = []
for row in more_rows:
    event = {"id": row['id'], "title": row['title'], "start": row['start'], "end": row['end'], "allDay": 1, "url": "", "color": row['color'], "extendedProps": {"company": row['company'], "description": row['description'], "type": row['type'], "tecnology": row['tecnology'], "state": row['state']}}
    more_events.append(event)

它们一起发送到浏览器:

...
events.extend(more_events)
return jsonify(events), 200
...

jsonify(events)将此JSON发送到浏览器(我在python代码上使用双引号,但jsonify将其替换为单引号):

[{'allDay': 1, 'color': 'blue', 'end': '2019-10-24T00:00:00.000Z', 'extendedProps': {'company': 'Company test', 'state': 'Active'}, 'groupId': '48', 'id': 27, 'start': '2019-10-23T00:00:00.000Z', 'title': 'A title', 'url': ''}, 
{'allDay': 1, 'color': 'blue', 'end': '2019-10-11T00:00:00.00.000Z', 'extendedProps': {'company': 'Company test', 'description': 'oapisdvañklsjdhalksjdflaksjdf', 'state': 'Active', 'tecnology': 'javascript+html', 'type': 'Cool'}, 'id': 74, 'start': '2019-10-07T00:00:00.00.000Z', 'title': 'owqsakjdflh', 'url': ''}, 
{'allDay': 1, 'color': 'blue', 'end': '2019-10-23T00:00:00.00.000Z', 'extendedProps': {'company': 'Company test', 'description': 'sdgsdfgwertwertwg', 'state': 'Active', 'tecnology': 'c', 'type': 'Cool'}, 'id': 75, 'start': '2019-10-21T00:00:00.00.000Z', 'title': '1eqwrwqer', 'url': ''}, 
{'allDay': 1, 'color': 'blue', 'end': '2019-11-07T00:00:00.00.000Z', 'extendedProps': {'company': 'Company test', 'description': 'asdfafasdfasdfasdf', 'state': 'Active', 'tecnology': 'java', 'type': 'Cool'}, 'id': 76, 'start': '2019-11-04T00:00:00.00.000Z', 'title': 'Bla bla bla', 'url': ''}]

问题是...作为事件打印的第一个元素,但不打印JSON上的其余元素。

我看不到我的错误在哪里或我在做什么错。

致谢。

1 个答案:

答案 0 :(得分:1)

我发现了问题(嗯,实际上是一个同事),就在这里:

第一个元素:'end':'2019-10-24T00:00:00.000Z' || 'start':'2019-10-23T00:00:00.000Z'

其他元素:'end': '2019-10-23T00:00:00.00.000Z' || 'start': '2019-10-21T00:00:00.00.000Z'

问题是:2019-10-24T 00:00:00 .000Z和2019-10-23T 00:00:00.00 .000Z

我使用此SQL比较日期(日期未存储在ISO 8601中):

SELECT id, ....., strftime('%Y-%m-%dT%H:%M:%fZ', start_date) AS start, strftime('%Y-%m-%dT%H:%M:%fZ', end_date) AS end, ...... 
FROM table 
WHERE state = 'Active' AND start > '....' AND end < '....'

我的问题是假设 SQlite strftime 等于 PYTHON strftime ,但不。

我正在使用以下(Python):'%Y-%m-%dT%H:%M:%S.%f Z',而不是以下版本(SQlite):'%Y -%m-%dT%H:%M:%f Z'

Python Doc

%S Second as a zero-padded decimal number.
%f Microsecond as a decimal number, zero-padded on the left.

Sqlite Doc

%S seconds: 00-59
%f fractional seconds: SS.SSS

因此请注意,请勿将python格式与sqlite格式混淆

致谢!