Compare commits

..

9 Commits

Author SHA1 Message Date
ostertun
29f83814ee Merge branch 'hotfix/new_follow2' 2024-02-18 13:19:12 +01:00
ostertun
744be24410 gitflow-hotfix-stash: new_follow2 2024-02-18 13:19:04 +01:00
ostertun
633e39ce5d Merge branch 'hotfix/new_follow' 2024-02-18 13:14:12 +01:00
ostertun
2e6eb25e68 gitflow-hotfix-stash: new_follow 2024-02-18 13:13:55 +01:00
ostertun
dc2ead3a07 Merge branch 'hotfix/a53.2' 2023-11-27 09:21:05 +01:00
ostertun
6b89acf422 gitflow-hotfix-stash: a53.2 2023-11-27 09:20:58 +01:00
ostertun
54ceae6ce0 Merge branch 'hotfix/a53' 2023-11-27 09:14:53 +01:00
ostertun
a6f0c8e0f5 a53 2023-11-27 09:14:45 +01:00
ostertun
fe90438cb3 gitflow-hotfix-stash: a53 2023-11-27 09:14:19 +01:00
4 changed files with 66 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
const DB_VERSION = 8;
const DB_VERSION = 9;
const USER_ID = localStorage.getItem('auth_user');
const USER_NAME = localStorage.getItem('auth_username');
@@ -163,6 +163,15 @@ function dbGetResultCalculated(regatta) {
if (results.length > 0) {
var gemeldet = results.length;
var started = [];
for (var i = 0; i < regatta['races']; i++) {
started[i] = 0;
for (id in results) {
if (results[id]['race' + (i + 1)] != 'DNC') {
started[i]++;
}
}
}
for (id in results) {
results[id]['finished'] = false;
@@ -179,24 +188,25 @@ function dbGetResultCalculated(regatta) {
results[id]['texts'][i] = race;
results[id]['finished'] = true;
} else {
var p1points = (regatta.a53 ? started[i] : gemeldet) + 1;
switch (race.toUpperCase()) {
// Nicht gestartet
case 'DNC': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not come
case 'DNS': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not started
case 'DNS': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Did not started
// Startfehler
case 'OCS': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // On course site
case 'UFD': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Uniform Flag Disqualified (disqu. nach 30.3)
case 'BFD': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Black Flag Disqualified (disqu. nach 30.4)
case 'OCS': results[id]['values'][i] = p1points; copy[i] = p1points; break; // On course site
case 'UFD': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Uniform Flag Disqualified (disqu. nach 30.3)
case 'BFD': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Black Flag Disqualified (disqu. nach 30.4)
// Nicht durch Ziel gegangen
case 'DNF': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Did not finish
case 'RET': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Retired (Aufgegeben)
case 'RAF': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Retired after finish
case 'DNF': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Did not finish
case 'RET': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Retired (Aufgegeben)
case 'RAF': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Retired after finish
// Kursfehler
case 'NSC': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Not sailed course
case 'NSC': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Not sailed course
// Disqualifizierun
case 'DSQ': results[id]['values'][i] = gemeldet + 1; copy[i] = gemeldet + 1; break; // Disqualified
case 'DNE': results[id]['values'][i] = gemeldet + 1; copy[i] = -1; break; // Disqualified, not excludable (disqu. kann nach 90.3(b) nicht gestrichen werden)
case 'DGM': results[id]['values'][i] = gemeldet + 1; copy[i] = -2; break; // Disqualification Gross Missconduct (kann nach 69.1(b)(2) nicht gestr. werden, grobes Fehlverhalten)
case 'DSQ': results[id]['values'][i] = p1points; copy[i] = p1points; break; // Disqualified
case 'DNE': results[id]['values'][i] = p1points; copy[i] = -1; break; // Disqualified, not excludable (disqu. kann nach 90.3(b) nicht gestrichen werden)
case 'DGM': results[id]['values'][i] = p1points; copy[i] = -2; break; // Disqualification Gross Missconduct (kann nach 69.1(b)(2) nicht gestr. werden, grobes Fehlverhalten)
// Unbekannt
default: results[id]['values'][i] = 0; copy[i] = 0; break;
}
@@ -224,9 +234,10 @@ function dbGetResultCalculated(regatta) {
var netto = 0;
for (var i = 0; i < regatta['races']; i ++) {
brutto += results[id]['values_all'][i];
if (copy[i] == -1) { results[id]['values'][i] = gemeldet + 1; }
/*if (copy[i] == -1) { results[id]['values'][i] = gemeldet + 1; }
else if (copy[i] == -2) { results[id]['values'][i] = gemeldet + 1; }
else { results[id]['values'][i] = copy[i]; }
else { results[id]['values'][i] = copy[i]; }*/
if (copy[i] == 0) results[id]['values'][i] = 0;
if (results[id]['values'][i] == 0) {
results[id]['texts'][i] = '[' + results[id]['texts'][i] + ']';
}
@@ -608,7 +619,7 @@ function sync() {
localTimes[entry['table']] = entry['time'];
});
syncInProgress = 13;
syncInProgress = 14;
var syncOkay = true;
log("[db] Sync Start");
$('#i-sync').addClass('fa-spin');
@@ -997,8 +1008,35 @@ function sync() {
syncInProgress --;
}
// FOLLOWS
getJSON(QUERY_URL + 'get_follows', function (code, data) {
if (code == 200) {
var os = db.transaction('follows', 'readwrite').objectStore('follows');
data.data.forEach(function (entry) {
os.put(entry);
});
os.openCursor().onsuccess = function (event) {
var cursor = event.target.result;
if (cursor) {
if (!data.keys.includes(parseInt(cursor.key))) {
os.delete(cursor.key);
}
cursor.continue();
} else {
syncInProgress -= 3;
syncInProgress --;
log('[db] follows synced, remaining:', syncInProgress);
}
};
} else {
log("[db] follows: Something went wrong (HTTP " + code + ")");
syncOkay = false;
syncInProgress --;
log('[db] follows failed, remaining:', syncInProgress);
}
});
} else {
syncInProgress -= 4;
}
// NEWS
@@ -1225,6 +1263,11 @@ function initDatabase() {
var osRankings = db.createObjectStore('rankings', { keyPath: 'id' });
}
if ((oldVersion < 9) && (newVersion >= 9)) {
log('[db] to version 9');
var osFollows = db.createObjectStore('follows', { keyPath: 'id' });
}
// Force resync after db update
if (oldVersion >= 1) {
var osUpdateTimes = upgradeTransaction.objectStore('update_times');

View File

@@ -85,12 +85,10 @@ var siteScript = async function() {
var user = await dbGetData('users', localStorage.getItem('auth_user'));
// Favorites
var follows = await dbGetData('follows');
var watched = [];
for (var i = 1; i <= 5; i ++) {
sailor_id = user['sailor' + i];
if (sailor_id != null) {
watched.push(await dbGetData('sailors', sailor_id));
}
for (var i in follows) {
watched.push(await dbGetData('sailors', follows[i].sailor));
}
if (watched.length > 0) {
var year = (new Date()).getFullYear();

View File

@@ -194,12 +194,10 @@ var siteScript = async function() {
if (isLoggedIn()) {
var user = await dbGetData('users', USER_ID);
var follows = await dbGetData('follows');
followedSailors = [];
for (var i = 1; i <= 5; i ++) {
sailor_id = user['sailor' + i];
if (sailor_id != null) {
followedSailors.push(await dbGetData('sailors', sailor_id));
}
for (var i in follows) {
followedSailors.push(await dbGetData('sailors', follows[i].sailor));
}
}

View File

@@ -1,5 +1,5 @@
<?php
define('PWA_VERSION', '1.12.1h5');
define('PWA_VERSION', '1.12.1h8');
?>