update postgresql branch

This commit is contained in:
Ben
2026-05-07 23:45:07 -04:00
parent cc0ca3979e
commit 327be48ade
23 changed files with 8817 additions and 8406 deletions
@@ -31,6 +31,24 @@ export class AddressSettingsService {
return await this.addressSettingsRepository.update({ address }, { bestDifficulty, bestDifficultyUserAgent });
}
public async updateBestDifficultyIfHigher(address: string, bestDifficulty: number, bestDifficultyUserAgent: string) {
await this.addressSettingsRepository
.createQueryBuilder()
.insert()
.into(AddressSettingsEntity)
.values({ address })
.orIgnore()
.execute();
return await this.addressSettingsRepository
.createQueryBuilder()
.update(AddressSettingsEntity)
.set({ bestDifficulty, bestDifficultyUserAgent })
.where('address = :address', { address })
.andWhere('"bestDifficulty" < :bestDifficulty', { bestDifficulty })
.execute();
}
public async createNew(address: string) {
return await this.addressSettingsRepository.save({ address });
}
@@ -46,10 +64,14 @@ export class AddressSettingsService {
// }
public async resetBestDifficultyAndShares() {
return await this.addressSettingsRepository.update({}, {
shares: 0,
bestDifficulty: 0
});
return await this.addressSettingsRepository
.createQueryBuilder()
.update(AddressSettingsEntity)
.set({
shares: 0,
bestDifficulty: 0
})
.execute();
}
public async getHighScores() {