如何在列表顶部显示最新信息,在底部显示旧信息

时间:2017-12-05 13:44:46

标签: python json firebase flask

我只想问一下我应该用什么做什么才能做到我的想法。

例如,从提取的当前firebase值变为Json,我可以得到:

enter image description here

通过以下代码:

   result1 = firebase.get('/Rooms/Room1/' + currentdate + '/Inspection/Scan-in/Inspector/', None)
    result2 = firebase.get('/Rooms/Room1/' + currentdate + '/Inspection/Scan-out/Inspector/', None)

for key in result1.keys():
       inspector = key
    timeout = result2[inspector]["Time"]



    result1datetime = firebase.get('/Rooms/Room1/'+ currentdate +'/Inspection/Scan-in/Inspector/'+ inspector +'/', None)





    for key in result1datetime.keys():
        key = sorted(result1datetime.keys())[-2]
        time = key
        print time



    print time

    ch1 = result1datetime[time]["Checklist"]["Entrance louver clean and dust-free"]
    # ch2 = result1datetime[time]["Checklist"]["Room plat number – clean and well-polished"]
    ch3 = result1datetime[time]["Checklist"]["Appearance door surface- in good condition"]
     ch4 = result1datetime[time]["Checklist"]["Let the door close by itself to test the door closure – in working order"]
    ch5 = result1datetime[time]["Checklist"]["Eye viewer and fire escape plan in order"]
    ch6 = result1datetime[time]["Checklist"]["Privacy Sign or Make Up Room Sign"]
     ch7 = result1datetime[time]["Checklist"]["Key card holder – in working order"]
    ch8 = result1datetime[time]["Checklist"]["Switches at the entrance working correctly"]

这是有效的,但我想做的是数据库何时获得更新。像图片中那样的新输入将位于其底部的最后一个输入的顶部

例如:

Scan-in: 2017-12-06
Time: Dec 6, 2017 4:58:00 AM
Time-out: Dec 5, 2017 4:58:21 AM
Inspection time: -1 day, 23:59:39
Inspector: trhf
Checklist: 

Scan-in: 2017-12-05
Time: Dec 5, 2017 4:58:00 AM
Time-out: Dec 5, 2017 4:58:21 AM
Inspection time: -1 day, 23:59:39
Inspector: trhf
Checklist: 

我一直在寻找实现这个目标的方法,但我一无所知。如果你是我,你会如何实现这个?你会用什么图书馆?非常感谢你!任何帮助都非常非常感谢!

0 个答案:

没有答案