Skip to content

Commit

Permalink
📊Presence: Fix by the amazing @johnwang16 🙏 #814
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Oct 18, 2024
1 parent 367a024 commit e24903a
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,38 @@ def upgradeDB(self):
WHERE e.row_num = 1;
""")

self.commitDB()


# handling the Convert_Events_to_Sessions / Sessions screens
self.sql.execute("""DROP VIEW IF EXISTS Convert_Events_to_Sessions;""")
self.sql.execute("""CREATE VIEW Convert_Events_to_Sessions AS SELECT EVE1.eve_MAC,
EVE1.eve_IP,
EVE1.eve_EventType AS eve_EventTypeConnection,
EVE1.eve_DateTime AS eve_DateTimeConnection,
CASE WHEN EVE2.eve_EventType IN ('Disconnected', 'Device Down') OR
EVE2.eve_EventType IS NULL THEN EVE2.eve_EventType ELSE '<missing event>' END AS eve_EventTypeDisconnection,
CASE WHEN EVE2.eve_EventType IN ('Disconnected', 'Device Down') THEN EVE2.eve_DateTime ELSE NULL END AS eve_DateTimeDisconnection,
CASE WHEN EVE2.eve_EventType IS NULL THEN 1 ELSE 0 END AS eve_StillConnected,
EVE1.eve_AdditionalInfo
FROM Events AS EVE1
LEFT JOIN
Events AS EVE2 ON EVE1.eve_PairEventRowID = EVE2.RowID
WHERE EVE1.eve_EventType IN ('New Device', 'Connected','Down Reconnected')
UNION
SELECT eve_MAC,
eve_IP,
'<missing event>' AS eve_EventTypeConnection,
NULL AS eve_DateTimeConnection,
eve_EventType AS eve_EventTypeDisconnection,
eve_DateTime AS eve_DateTimeDisconnection,
0 AS eve_StillConnected,
eve_AdditionalInfo
FROM Events AS EVE1
WHERE (eve_EventType = 'Device Down' OR
eve_EventType = 'Disconnected') AND
EVE1.eve_PairEventRowID IS NULL;
""")

self.commitDB()

# Init the AppEvent database table
AppEvent_obj(self)

Expand Down

0 comments on commit e24903a

Please sign in to comment.