-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
4,186 additions
and
1,659 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,77 @@ | ||
import SQLite from 'tauri-plugin-sqlite-api'; | ||
import { readBinaryFile, readTextFile } from '@tauri-apps/api/fs'; | ||
|
||
// const readKudosDb = async ({ dbFile }) => { | ||
// return []; | ||
// }; | ||
|
||
const readKudosDb = async ({ dbFile }) => { | ||
console.log('dbFile', { dbFile }); | ||
const db = await SQLite.open(dbFile); | ||
if (!dbFile) { | ||
throw new Error('dbFile is not defined'); | ||
} | ||
console.log('dbFile', { dbFile, db }); | ||
const exists = await db.select( | ||
`SELECT name FROM sqlite_master WHERE type='table' AND name='kudos'` | ||
); | ||
if (!exists || exists.length === 0) { | ||
throw new Error('not a valid kudos database'); | ||
} | ||
console.log('exists', { exists }); | ||
const result = await db.select( | ||
`SELECT identifier, cohort, weight, createTime, description, id, context | ||
FROM kudos ORDER BY createTime ASC` | ||
); | ||
//.where("cohort", "=", `${cohort}`) | ||
//.where("user", "=", user) | ||
// .orderBy("createTime", "asc"); | ||
|
||
// iterate through result, JSON.parse context | ||
result.forEach((row) => { | ||
// read dbFile | ||
// all data, newline delimited json | ||
const file = await readTextFile(dbFile); | ||
// parse the data as json, converting from buffer to text | ||
const data = file.toString(); | ||
|
||
// split the data into lines | ||
const lines = data.split('\n'); | ||
console.log('lines', lines); | ||
|
||
// for each | ||
// parse the line as json | ||
// add to array | ||
const result = lines.map((line) => { | ||
let row = {}; | ||
try { | ||
row.context = JSON.parse(row.context); | ||
row = JSON.parse(line); | ||
row.context = line; | ||
row.weight = row.weight || 1; | ||
} catch (e) { | ||
// TODO: throw error/event | ||
console.log('error parsing context', { row, e }); | ||
console.log('error parsing line', { line, e }); | ||
return null; | ||
} | ||
return row; | ||
}); | ||
console.log({ result }); | ||
|
||
// db.destroy(); | ||
const isClosed = await db.close(); | ||
|
||
console.log({ result }); | ||
return result; | ||
// const parsed = JSON.parse(file.toLocaleString()); | ||
// console.log('file', parsed); | ||
// const db = await SQLite.open(dbFile); | ||
// if (!dbFile) { | ||
// throw new Error('dbFile is not defined'); | ||
// } | ||
// console.log('dbFile', { dbFile, db }); | ||
// const exists = await db.select( | ||
// `SELECT name FROM sqlite_master WHERE type='table' AND name='kudos'` | ||
// ); | ||
// if (!exists || exists.length === 0) { | ||
// throw new Error('not a valid kudos database'); | ||
// } | ||
// console.log('exists', { exists }); | ||
// const result = await db.select( | ||
// `SELECT identifier, cohort, weight, createTime, description, id, context | ||
// FROM kudos ORDER BY createTime ASC` | ||
// ); | ||
// //.where("cohort", "=", `${cohort}`) | ||
// //.where("user", "=", user) | ||
// // .orderBy("createTime", "asc"); | ||
|
||
// // iterate through result, JSON.parse context | ||
// result.forEach((row) => { | ||
// try { | ||
// row.context = JSON.parse(row.context); | ||
// } catch (e) { | ||
// // TODO: throw error/event | ||
// console.log('error parsing context', { row, e }); | ||
// } | ||
// }); | ||
|
||
// // db.destroy(); | ||
// const isClosed = await db.close(); | ||
|
||
// return result; | ||
}; | ||
|
||
export { readKudosDb }; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
d911d42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ident-agency-net-enola – ./ident-agency/packages/enola
ident-agency-net-enola-loremlabs.vercel.app
ident-agency-net-enola.vercel.app
ident-agency-net-enola-git-main-loremlabs.vercel.app
d911d42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
www-kudos-community – ./kudos-community/www
www-kudos-community-loremlabs.vercel.app
www-kudos-community.vercel.app
www-kudos-community-git-main-loremlabs.vercel.app
www.kudos.community
kudos.community