Replay analyze error handling
This commit is contained in:
parent
e26ae3a6b8
commit
556667d811
|
@ -4,9 +4,9 @@
|
||||||
/// To regenerate, run: `dart run slang`
|
/// To regenerate, run: `dart run slang`
|
||||||
///
|
///
|
||||||
/// Locales: 2
|
/// Locales: 2
|
||||||
/// Strings: 1004 (502 per locale)
|
/// Strings: 1008 (504 per locale)
|
||||||
///
|
///
|
||||||
/// Built on 2024-01-22 at 17:10 UTC
|
/// Built on 2024-01-22 at 19:27 UTC
|
||||||
|
|
||||||
// coverage:ignore-file
|
// coverage:ignore-file
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
|
@ -254,6 +254,8 @@ class Translations implements BaseTranslations<AppLocale, Translations> {
|
||||||
String get statsFor => 'Stats for';
|
String get statsFor => 'Stats for';
|
||||||
String get matchLength => 'Match Length';
|
String get matchLength => 'Match Length';
|
||||||
String get roundLength => 'Round Length';
|
String get roundLength => 'Round Length';
|
||||||
|
String get replayIssue => 'Can\'t process replay';
|
||||||
|
String get matchIsTooOld => 'Replay is not available';
|
||||||
String get winner => 'Winner';
|
String get winner => 'Winner';
|
||||||
String get registred => 'Registred';
|
String get registred => 'Registred';
|
||||||
String get playedTL => 'Played Tetra League';
|
String get playedTL => 'Played Tetra League';
|
||||||
|
@ -840,6 +842,8 @@ class _StringsRu implements Translations {
|
||||||
@override String get statsFor => 'Статистика за';
|
@override String get statsFor => 'Статистика за';
|
||||||
@override String get matchLength => 'Продолжительность матча';
|
@override String get matchLength => 'Продолжительность матча';
|
||||||
@override String get roundLength => 'Продолжительность раунда';
|
@override String get roundLength => 'Продолжительность раунда';
|
||||||
|
@override String get replayIssue => 'Ошибка обработки повтора';
|
||||||
|
@override String get matchIsTooOld => 'Информация о повторе недоступна';
|
||||||
@override String get winner => 'Победитель';
|
@override String get winner => 'Победитель';
|
||||||
@override String get registred => 'Зарегистрирован';
|
@override String get registred => 'Зарегистрирован';
|
||||||
@override String get playedTL => 'Играл в Тетра Лигу';
|
@override String get playedTL => 'Играл в Тетра Лигу';
|
||||||
|
@ -1418,6 +1422,8 @@ extension on Translations {
|
||||||
case 'statsFor': return 'Stats for';
|
case 'statsFor': return 'Stats for';
|
||||||
case 'matchLength': return 'Match Length';
|
case 'matchLength': return 'Match Length';
|
||||||
case 'roundLength': return 'Round Length';
|
case 'roundLength': return 'Round Length';
|
||||||
|
case 'replayIssue': return 'Can\'t process replay';
|
||||||
|
case 'matchIsTooOld': return 'Replay is not available';
|
||||||
case 'winner': return 'Winner';
|
case 'winner': return 'Winner';
|
||||||
case 'registred': return 'Registred';
|
case 'registred': return 'Registred';
|
||||||
case 'playedTL': return 'Played Tetra League';
|
case 'playedTL': return 'Played Tetra League';
|
||||||
|
@ -1930,6 +1936,8 @@ extension on _StringsRu {
|
||||||
case 'statsFor': return 'Статистика за';
|
case 'statsFor': return 'Статистика за';
|
||||||
case 'matchLength': return 'Продолжительность матча';
|
case 'matchLength': return 'Продолжительность матча';
|
||||||
case 'roundLength': return 'Продолжительность раунда';
|
case 'roundLength': return 'Продолжительность раунда';
|
||||||
|
case 'replayIssue': return 'Ошибка обработки повтора';
|
||||||
|
case 'matchIsTooOld': return 'Информация о повторе недоступна';
|
||||||
case 'winner': return 'Победитель';
|
case 'winner': return 'Победитель';
|
||||||
case 'registred': return 'Зарегистрирован';
|
case 'registred': return 'Зарегистрирован';
|
||||||
case 'playedTL': return 'Играл в Тетра Лигу';
|
case 'playedTL': return 'Играл в Тетра Лигу';
|
||||||
|
|
|
@ -30,6 +30,8 @@ class SzyForbidden implements Exception {}
|
||||||
|
|
||||||
class SzyNotFound implements Exception {}
|
class SzyNotFound implements Exception {}
|
||||||
|
|
||||||
|
class ReplayNotAvalable implements Exception {}
|
||||||
|
|
||||||
class TetrioReplayAlreadyExist implements Exception {}
|
class TetrioReplayAlreadyExist implements Exception {}
|
||||||
|
|
||||||
class P1nkl0bst3rInternalProblem implements Exception {}
|
class P1nkl0bst3rInternalProblem implements Exception {}
|
||||||
|
|
|
@ -57,7 +57,7 @@ const String createTetrioTLReplayStats = '''
|
||||||
CREATE TABLE IF NOT EXISTS "tetrioTLReplayStats" (
|
CREATE TABLE IF NOT EXISTS "tetrioTLReplayStats" (
|
||||||
"id" TEXT NOT NULL,
|
"id" TEXT NOT NULL,
|
||||||
"data" TEXT NOT NULL,
|
"data" TEXT NOT NULL,
|
||||||
"freyhoe" TEXT NOT NULL,
|
"freyhoe" TEXT,
|
||||||
PRIMARY KEY("id")
|
PRIMARY KEY("id")
|
||||||
)
|
)
|
||||||
''';
|
''';
|
||||||
|
@ -193,11 +193,12 @@ class TetrioService extends DB {
|
||||||
return replayFile.path;
|
return replayFile.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ReplayData> analyzeReplay(String replayID) async{
|
Future<ReplayData> analyzeReplay(String replayID, bool isAvailable) async{
|
||||||
await ensureDbIsOpen();
|
await ensureDbIsOpen();
|
||||||
final db = getDatabaseOrThrow();
|
final db = getDatabaseOrThrow();
|
||||||
final results = await db.query(tetrioTLReplayStatsTable, where: '$idCol = ?', whereArgs: [replayID]);
|
final results = await db.query(tetrioTLReplayStatsTable, where: '$idCol = ?', whereArgs: [replayID]);
|
||||||
if (results.isNotEmpty) return ReplayData.fromJson(jsonDecode(results.first["data"].toString()));
|
if (results.isNotEmpty) return ReplayData.fromJson(jsonDecode(results.first["data"].toString()));
|
||||||
|
if (!isAvailable) throw ReplayNotAvalable();
|
||||||
Map<String, dynamic> toAnalyze = jsonDecode((await szyGetReplay(replayID))[0]);
|
Map<String, dynamic> toAnalyze = jsonDecode((await szyGetReplay(replayID))[0]);
|
||||||
ReplayData data = ReplayData.fromJson(toAnalyze);
|
ReplayData data = ReplayData.fromJson(toAnalyze);
|
||||||
saveReplayStats(data);
|
saveReplayStats(data);
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TlMatchResultState extends State<TlMatchResultView> {
|
||||||
_scrollController = ScrollController();
|
_scrollController = ScrollController();
|
||||||
rounds = [DropdownMenuItem(value: -1, child: Text(t.match))];
|
rounds = [DropdownMenuItem(value: -1, child: Text(t.match))];
|
||||||
rounds.addAll([for (int i = 0; i < widget.record.endContext.first.secondaryTracking.length; i++) DropdownMenuItem(value: i, child: Text(t.roundNumber(n: i+1)))]);
|
rounds.addAll([for (int i = 0; i < widget.record.endContext.first.secondaryTracking.length; i++) DropdownMenuItem(value: i, child: Text(t.roundNumber(n: i+1)))]);
|
||||||
replayData = teto.analyzeReplay(widget.record.replayId);
|
replayData = teto.analyzeReplay(widget.record.replayId, widget.record.replayAvalable);
|
||||||
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS){
|
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS){
|
||||||
windowManager.getTitle().then((value) => oldWindowTitle = value);
|
windowManager.getTitle().then((value) => oldWindowTitle = value);
|
||||||
windowManager.setTitle("Tetra Stats: ${widget.record.endContext.firstWhere((element) => element.userId == widget.initPlayerId).username.toUpperCase()} ${t.vs} ${widget.record.endContext.firstWhere((element) => element.userId != widget.initPlayerId).username.toUpperCase()} ${t.inTLmatch} ${dateFormat.format(widget.record.timestamp)}");
|
windowManager.setTitle("Tetra Stats: ${widget.record.endContext.firstWhere((element) => element.userId == widget.initPlayerId).username.toUpperCase()} ${t.vs} ${widget.record.endContext.firstWhere((element) => element.userId != widget.initPlayerId).username.toUpperCase()} ${t.inTLmatch} ${dateFormat.format(widget.record.timestamp)}");
|
||||||
|
@ -211,7 +211,25 @@ class TlMatchResultState extends State<TlMatchResultView> {
|
||||||
return Center(child: Text("${t.roundLength}: ${time.inMinutes}:${secs.format(time.inMicroseconds /1000000 % 60)}\n${t.winner}: ${snapshot.data!.roundWinners[roundSelector][1]}", textAlign: TextAlign.center,));
|
return Center(child: Text("${t.roundLength}: ${time.inMinutes}:${secs.format(time.inMicroseconds /1000000 % 60)}\n${t.winner}: ${snapshot.data!.roundWinners[roundSelector][1]}", textAlign: TextAlign.center,));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return Text("${snapshot.error.toString()}\n${snapshot.stackTrace}", textAlign: TextAlign.center);
|
String reason;
|
||||||
|
switch (snapshot.error.runtimeType){
|
||||||
|
case ReplayNotAvalable:
|
||||||
|
reason = t.matchIsTooOld;
|
||||||
|
break;
|
||||||
|
case SzyNotFound:
|
||||||
|
reason = t.matchIsTooOld;
|
||||||
|
break;
|
||||||
|
case SzyForbidden:
|
||||||
|
reason = t.errors.replayRejected;
|
||||||
|
break;
|
||||||
|
case SzyTooManyRequests:
|
||||||
|
reason = t.errors.tooManyRequests;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
reason = snapshot.error.toString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return Text("${t.replayIssue}: $reason", textAlign: TextAlign.center);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,8 @@
|
||||||
"statsFor": "Stats for",
|
"statsFor": "Stats for",
|
||||||
"matchLength": "Match Length",
|
"matchLength": "Match Length",
|
||||||
"roundLength": "Round Length",
|
"roundLength": "Round Length",
|
||||||
|
"replayIssue": "Can't process replay",
|
||||||
|
"matchIsTooOld": "Replay is not available",
|
||||||
"winner": "Winner",
|
"winner": "Winner",
|
||||||
"registred": "Registred",
|
"registred": "Registred",
|
||||||
"playedTL": "Played Tetra League",
|
"playedTL": "Played Tetra League",
|
||||||
|
|
|
@ -119,6 +119,8 @@
|
||||||
"statsFor": "Статистика за",
|
"statsFor": "Статистика за",
|
||||||
"matchLength": "Продолжительность матча",
|
"matchLength": "Продолжительность матча",
|
||||||
"roundLength": "Продолжительность раунда",
|
"roundLength": "Продолжительность раунда",
|
||||||
|
"replayIssue": "Ошибка обработки повтора",
|
||||||
|
"matchIsTooOld": "Информация о повторе недоступна",
|
||||||
"winner": "Победитель",
|
"winner": "Победитель",
|
||||||
"registred": "Зарегистрирован",
|
"registred": "Зарегистрирован",
|
||||||
"playedTL": "Играл в Тетра Лигу",
|
"playedTL": "Играл в Тетра Лигу",
|
||||||
|
|
Loading…
Reference in New Issue