small fixes

This commit is contained in:
dan63047 2023-07-22 15:07:57 +03:00
parent 0e251bd01c
commit fd8c1fc16d
3 changed files with 23 additions and 19 deletions

View File

@ -10,7 +10,7 @@ If you want an app, you can find it [here](https://github.com/dan63047/TetraStat
# Available functionality
- Advanced stats for players
- Rank cutoffs and averages
- Sqlite Database and service, that can work with it
- Sqlite database, that can store all data
- Comparison to players, rank averages, and player stats from the past
- Stats Calculator
- Player history in charts

View File

@ -81,7 +81,7 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
@override
void initState() {
teto.open();
initDB();
_scrollController = ScrollController();
_tabController = TabController(length: 6, vsync: this);
if (widget.player != null){
@ -111,6 +111,10 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
});
}
void initDB() async{
await teto.open();
}
Future<List> fetch(String nickOrID, {bool fetchHistory = false}) async {
TetrioPlayer me = await teto.fetchPlayer(nickOrID);
_searchFor = me.userId;
@ -121,6 +125,22 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
List<TetrioPlayer> states = [];
TetraLeagueAlpha? compareWith;
var uniqueTL = <dynamic>{};
if (isTracking){
await teto.storeState(me);
await teto.saveTLMatchesFromStream(await teto.getTLStream(me.userId));
tlMatches.addAll(await teto.getTLMatchesbyPlayerID(me.userId));
for (var match in tlStream.records) {
if (!tlMatches.contains(match)) tlMatches.add(match);
}
tlMatches.sort((a, b) {
if(a.timestamp.isBefore(b.timestamp)) return 1;
if(a.timestamp.isAtSameMomentAs(b.timestamp)) return 0;
if(a.timestamp.isAfter(b.timestamp)) return -1;
return 0;
});
} else{
tlMatches = tlStream.records;
}
if(fetchHistory) await teto.fetchAndsaveTLHistory(_searchFor);
states.addAll(await teto.getPlayer(me.userId));
for (var element in states) {
@ -151,22 +171,6 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
DropdownMenuItem(value: [for (var tl in uniqueTL) if (tl.estTr != null) FlSpot(tl.timestamp.millisecondsSinceEpoch.toDouble(), tl.estTr!.esttr)], child: Text(t.statCellNum.estOfTR.replaceAll(RegExp(r'\n'), " "))),
DropdownMenuItem(value: [for (var tl in uniqueTL) if (tl.esttracc != null) FlSpot(tl.timestamp.millisecondsSinceEpoch.toDouble(), tl.esttracc!)], child: Text(t.statCellNum.accOfEst.replaceAll(RegExp(r'\n'), " "))),
];
if (isTracking){
await teto.storeState(me);
await teto.saveTLMatchesFromStream(await teto.getTLStream(me.userId));
tlMatches.addAll(await teto.getTLMatchesbyPlayerID(me.userId));
for (var match in tlStream.records) {
if (!tlMatches.contains(match)) tlMatches.add(match);
}
tlMatches.sort((a, b) {
if(a.timestamp.isBefore(b.timestamp)) return 1;
if(a.timestamp.isAtSameMomentAs(b.timestamp)) return 0;
if(a.timestamp.isAfter(b.timestamp)) return -1;
return 0;
});
} else{
tlMatches = tlStream.records;
}
Map<String, dynamic> records = await teto.fetchRecords(me.userId);
return [me, records, states, tlMatches, compareWith, isTracking];
}

View File

@ -2,7 +2,7 @@ name: tetra_stats
description: Track your and other player stats in TETR.IO
publish_to: 'none'
version: 1.0.0+5
version: 1.0.1+6
environment:
sdk: '>=2.19.6 <3.0.0'