File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,10 @@ class Base(DeclarativeBase):
1616
1717class HitsInfo (Base ):
1818 __tablename__ = "hits_info"
19-
20- hits : Mapped [int ] = mapped_column (primary_key = True )
19+
20+ time : Mapped [int ] = mapped_column (primary_key = True )
21+ hits : Mapped [int ]
2122 bytes : Mapped [int ]
22- time : Mapped [int ]
2323
2424
2525class AgentInfo (Base ):
@@ -37,7 +37,10 @@ def writeHits(hits: int, bytes: int) -> None:
3737 if hits == 0 and bytes == 0 :
3838 return
3939 session .add (HitsInfo (hits = hits , bytes = bytes , time = int (time .time ())))
40- session .commit ()
40+ try :
41+ session .commit ()
42+ except Exception :
43+ session .rollback ()
4144
4245
4346def writeAgent (agent : str , hits : int ) -> None :
@@ -46,7 +49,10 @@ def writeAgent(agent: str, hits: int) -> None:
4649 agent_info .hits += hits
4750 else :
4851 session .add (AgentInfo (agent = agent , hits = hits ))
49- session .commit ()
52+ try :
53+ session .commit ()
54+ except Exception :
55+ session .rollback ()
5056
5157
5258def getHourlyHits () -> Dict [str , List [Dict [str , int ]]]:
You can’t perform that action at this time.
0 commit comments