Smashed some bugs; migrated to caprover appwrite
This commit is contained in:
@@ -6,7 +6,7 @@ class AppwriteService {
|
||||
collectionId = "ryan";
|
||||
constructor() {
|
||||
this.appwrite = new Client()
|
||||
.setEndpoint("http://ryanpandya.com:8080/v1")
|
||||
.setEndpoint("https://db.ryanpandya.com/v1")
|
||||
.setProject("lifetracker");
|
||||
this.database = new Databases(this.appwrite);
|
||||
this.account = new Account(this.appwrite);
|
||||
@@ -43,7 +43,7 @@ class AppwriteService {
|
||||
this.databaseId,
|
||||
this.collectionId,
|
||||
date,
|
||||
{ date: new Date(date), hours, mood, comments }
|
||||
{ hours, mood, comments }
|
||||
);
|
||||
};
|
||||
|
||||
@@ -75,20 +75,33 @@ class AppwriteService {
|
||||
).documents[0];
|
||||
const referenceDate = DateTime.fromISO(firstEntry.date).toUTC();
|
||||
|
||||
const offset = Math.floor(date.diff(referenceDate).as("days")) - 1;
|
||||
let offset = 0; //Math.floor(date.diff(referenceDate).as("days")) - 1;
|
||||
|
||||
if (numEntries == null) {
|
||||
numEntries =
|
||||
Math.floor(DateTime.now().diff(referenceDate).as("days")) + 7;
|
||||
}
|
||||
} // 142 as of May 16, 2023
|
||||
|
||||
return (
|
||||
await this.database.listDocuments(this.databaseId, this.collectionId, [
|
||||
var documents = []; // Start with nothing loaded
|
||||
var limit = 100;
|
||||
while(limit > 0){ // Make repeated requests until we hit the numEntries
|
||||
let newEntries = (await this.database.listDocuments(
|
||||
this.databaseId, this.collectionId, [
|
||||
Query.orderAsc("date"),
|
||||
Query.offset(offset),
|
||||
Query.limit(numEntries),
|
||||
])
|
||||
).documents;
|
||||
Query.offset(offset), // 0
|
||||
Query.limit(limit), // 100
|
||||
])).documents;
|
||||
|
||||
documents.push(newEntries);
|
||||
documents = documents.flat();
|
||||
|
||||
offset += limit; // Increment offset by the amount we just loaded
|
||||
limit = numEntries - offset; // This might not work
|
||||
// console.log(numEntries + " entries; offset " + offset + "; limit " + limit);
|
||||
|
||||
};
|
||||
|
||||
return documents;
|
||||
};
|
||||
|
||||
logout = () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { defineStore } from "pinia";
|
||||
import { Client, Account } from "appwrite";
|
||||
|
||||
const appwriteclient = new Client()
|
||||
.setEndpoint("http://ryanpandya.com:8080/v1")
|
||||
.setEndpoint("https://db.ryanpandya.com/v1")
|
||||
.setProject("lifetracker");
|
||||
|
||||
const account = new Account(appwriteclient);
|
||||
|
||||
@@ -1,41 +1,29 @@
|
||||
<script>
|
||||
import { defineComponent } from "vue";
|
||||
import { HotTable } from "@handsontable/vue3";
|
||||
import { registerAllModules } from "handsontable/registry";
|
||||
import "handsontable/dist/handsontable.full.css";
|
||||
import appwrite from "@/services/appwrite";
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
// register Handsontable's modules
|
||||
registerAllModules();
|
||||
|
||||
const ExampleComponent = defineComponent({
|
||||
components: {
|
||||
HotTable,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
hotSettings: {
|
||||
data: [
|
||||
["A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1", "I1", "J1"],
|
||||
["A2", "B2", "C2", "D2", "E2", "F2", "G2", "H2", "I2", "J2"],
|
||||
["A3", "B3", "C3", "D3", "E3", "F3", "G3", "H3", "I3", "J3"],
|
||||
["A4", "B4", "C4", "D4", "E4", "F4", "G4", "H4", "I4", "J4"],
|
||||
["A5", "B5", "C5", "D5", "E5", "F5", "G5", "H5", "I5", "J5"],
|
||||
["A6", "B6", "C6", "D6", "E6", "F6", "G6", "H6", "I6", "J6"],
|
||||
],
|
||||
colHeaders: true,
|
||||
height: "auto",
|
||||
licenseKey: "non-commercial-and-evaluation",
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default ExampleComponent;
|
||||
export default {
|
||||
methods: {
|
||||
rewrite(d) {
|
||||
const emptyEntry = {
|
||||
date: d.toISODate(),
|
||||
hours: [],
|
||||
mood: null,
|
||||
comments: "",
|
||||
};
|
||||
appwrite.updateEntry(emptyEntry);
|
||||
console.log("Updated " + d.toISODate());
|
||||
},
|
||||
rewriteEntries() {
|
||||
const startDate = DateTime.fromISO("2023-05-19");
|
||||
const endDate = DateTime.fromISO("2023-12-31");
|
||||
for (let d = startDate; d <= endDate; d = d.plus({ days: 1 })) {
|
||||
setTimeout(this.rewrite(d), 500);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div id="example1">
|
||||
<hot-table :settings="hotSettings"></hot-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style></style>
|
||||
<button @click="rewriteEntries">Rewrite entries</button>
|
||||
</template>
|
||||
@@ -301,24 +301,7 @@ const ExampleComponent = defineComponent({
|
||||
updateTable() {
|
||||
this.hotRef = this.$refs.wrapper.hotInstance;
|
||||
this.hotRef.loadData(this.entries);
|
||||
},
|
||||
rewrite(d) {
|
||||
const emptyEntry = {
|
||||
date: d.toISODate(),
|
||||
hours: [],
|
||||
mood: null,
|
||||
comments: "",
|
||||
};
|
||||
appwrite.updateEntry(emptyEntry);
|
||||
console.log("Updated " + d.toISODate());
|
||||
},
|
||||
rewriteEntries() {
|
||||
const startDate = DateTime.fromISO("2023-12-10");
|
||||
const endDate = DateTime.fromISO("2023-12-31");
|
||||
for (let d = startDate; d <= endDate; d = d.plus({ days: 1 })) {
|
||||
setTimeout(this.rewrite(d), 500);
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user