Skip to content

Commit

Permalink
Fix bug with PB tie breakers and add new version script to package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
dmint789 committed Dec 30, 2022
1 parent 94ed774 commit e153419
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ android {
applicationId "com.stat_tracker"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 3
versionCode 4
versionName "0.4.1"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

Expand Down
12 changes: 6 additions & 6 deletions android/app/src/main/assets/index.android.bundle

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions app/redux/mainSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const verbose = true;

// The return value is whether or not the PB got updated
const updateStatTypePB = (state: any, statType: IStatType, entry: IEntry): boolean => {
if (verbose) console.log(`Checking if entry ${entry.id} has the PB for stat type ${statType.name}`);

let pbUpdated = false;
const stat = entry.stats.find((el: IStat) => el.type === statType.id);

Expand All @@ -43,7 +45,10 @@ const updateStatTypePB = (state: any, statType: IStatType, entry: IEntry): boole
(stat.values[0] > statType.pbs.allTime.result && statType.higherIsBetter) ||
(stat.values[0] < statType.pbs.allTime.result && !statType.higherIsBetter) ||
(stat.values[0] === statType.pbs.allTime.result &&
!isNewerOrSameDate(entry.date, state.entries[0].date))
!isNewerOrSameDate(
entry.date,
state.entries.find((el) => el.id === statType.pbs.allTime.entryId).date,
))
) {
statType.pbs.allTime.entryId = entry.id;
statType.pbs.allTime.result = stat.values[0] as number;
Expand Down Expand Up @@ -79,7 +84,10 @@ const updateStatTypePB = (state: any, statType: IStatType, entry: IEntry): boole
(stat.multiValueStats[convertKey(key)] > pbs[key] && statType.higherIsBetter) ||
(stat.multiValueStats[convertKey(key)] < pbs[key] && !statType.higherIsBetter) ||
(stat.multiValueStats[convertKey(key)] === pbs[key] &&
!isNewerOrSameDate(entry.date, state.entries[0].date))
!isNewerOrSameDate(
entry.date,
state.entries.find((el) => el.id === statType.pbs.allTime.entryId[key]).date,
))
) {
statType.pbs.allTime.entryId[key] = entry.id;
statType.pbs.allTime.result[key] = stat.multiValueStats[convertKey(key)];
Expand Down Expand Up @@ -107,6 +115,8 @@ const updatePBs = (state: any, entry: IEntry, mode: 'add' | 'edit' | 'delete') =

for (let statType of state.statTypes) {
if (statType.trackPBs && statType.variant === StatTypeVariant.NUMBER) {
if (verbose) console.log(`Updating PB for stat type ${statType.name}`);

let pbUpdated = false;

// Update PB if it could have gotten better or it's a tie, but happened earlier
Expand Down Expand Up @@ -304,7 +314,6 @@ const mainSlice = createSlice({
editStatType: (state, action: PayloadAction<IStatType>) => {
state.statTypes = state.statTypes.map((el) => {
if (el.id === action.payload.id) {
console.log('ST', JSON.stringify(action.payload), JSON.stringify(el));
if (el.trackPBs && !action.payload.trackPBs) {
delete action.payload.pbs;
} else if (
Expand Down
2 changes: 1 addition & 1 deletion app/shared/StorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as ScopedStorage from 'react-native-scoped-storage';
import { formatDate } from './GlobalFunctions';
import { IStatCategory, IBackupData, dataPoints } from './DataStructure';

const verbose = true;
const verbose = false;

export const getData = async (categoryId: number, request: string) => {
const key: string = categoryId + '_' + request;
Expand Down
4 changes: 2 additions & 2 deletions ios/Stat_Tracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Stat_Tracker/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -511,7 +511,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
INFOPLIST_FILE = Stat_Tracker/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
2 changes: 1 addition & 1 deletion ios/Stat_Tracker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3</string>
<string>4</string>
<key>LSRequiresIPhoneOS</key>
<true />
<key>NSAppTransportSecurity</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/Stat_TrackerTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3</string>
<string>4</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"emulator": "emulator -avd Pixel_3a_API_31",
"rn-upgrade": "react-native upgrade",
"rn-new-ver": "react-native-version --never-amend",
"git-new-ver": "echo Version: && read VERSION && git tag -af $VERSION -m \"Version $VERSION\" && git push -f origin --tags",
"new-version": "yarn rn-new-ver && VER=$(jq -r .version ./package.json) && git tag -af \"v$VER\" -m \"Version $VER\" && git push -f origin --tags && git tag",
"test": "jest",
"lint": "eslint ."
},
Expand Down

0 comments on commit e153419

Please sign in to comment.