@@ -100,16 +100,31 @@ class Dashboard(Activity): ...
100100
101101@dataclass (slots = True )
102102class PlayingPartial (Activity ):
103+ """Partial Playing Match.
104+
105+ Partial in a sense that full `PlayingMatch` objects get built from objects of `PlayingPartial` class.
106+ """
107+
103108 watchable_game_id : str
104109
105110
106111@dataclass (slots = True )
107112class SpectatingPartial (Activity ):
113+ """Partial Spectating Match.
114+
115+ Partial in a sense that full `SpectatingMatch` objects get built from objects of `SpectatingPartial` class.
116+ """
117+
108118 watching_server : str
109119
110120
111121@dataclass (slots = True )
112122class UnsupportedPartial (Activity ):
123+ """Partial Unsupported Match.
124+
125+ Partial in a sense that full `UnsupportedMatch` objects get built from objects of `UnsupportedPartial` class.
126+ """
127+
113128 msg : str
114129
115130
@@ -1130,10 +1145,9 @@ async def process_pending_matches(self) -> None:
11301145 log .debug ("Processing pending matches." )
11311146
11321147 query = """
1133- SELECT m.match_id
1134- FROM ttv_dota_matches m
1135- JOIN ttv_dota_match_players p ON m.match_id = p.match_id
1136- WHERE m.outcome IS NULL AND m.live = $1;
1148+ SELECT match_id, failed
1149+ FROM ttv_dota_matches
1150+ WHERE outcome IS NULL AND live = $1 AND failed < 12;
11371151 """
11381152 rows = await self .bot .pool .fetch (query , LiveIndicator .Pending )
11391153 if not rows :
@@ -1142,7 +1156,23 @@ async def process_pending_matches(self) -> None:
11421156 return
11431157
11441158 for row in rows :
1145- minimal = await self .bot .dota .create_partial_match (row ["match_id" ]).minimal ()
1159+ try :
1160+ # If streamer disconnects before ancient falls (i.e., preemptive disconnects or when game is "Safe to leave")
1161+ # Then `.minimal` won't give any results as the game is still live but streamer's RP is different
1162+ # So we need to deal with errors of not getting response from it.
1163+ # This also happens if streamer disconnects-reconnects in the middle of the match.
1164+ minimal = await self .bot .dota .create_partial_match (row ["match_id" ]).minimal ()
1165+ except ValueError :
1166+ # this way any matches that errored out more 12 times gonna be ignored
1167+ # not sure how I feel about such solution;
1168+ query = """
1169+ UPDATE ttv_dota_matches
1170+ SET failed = failed + 1
1171+ WHERE match_id = $1;
1172+ """
1173+ await self .bot .pool .execute (query , row ["match_id" ])
1174+ continue
1175+
11461176 query = """
11471177 UPDATE ttv_dota_matches
11481178 SET outcome = $1, live = $3
0 commit comments