10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 13:53:48 +01:00

Merge pull request #2 from scemama/master

Fast loading time
This commit is contained in:
mveril 2020-11-20 11:07:22 +01:00 committed by GitHub
commit 938e2459c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 77 additions and 25 deletions

31
.github/workflows/gh-pages.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: github pages
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: refresh apt
run: sudo apt-get update
- name: install dependencies
run: sudo apt-get install hugo
- name: install theme
run: git submodule update --init --recursive
- name: make
run: make
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public

View File

@ -101,16 +101,18 @@ draft: false
await loadFiles() await loadFiles()
} }
async function loadFiles() { async function loadFiles() {
const db = await indexDB.loadAsync()
const data = await loadAllData()
processingIndicator.isActive = true processingIndicator.isActive = true
var data = await loadAllData()
window.defaultDats = [] window.defaultDats = []
for (const sub of Object.values(data)) { for (const sub of Object.values(data)) {
for (const exSet of uniq(sub.map(d => d.set))) { for (const exSet of uniq(sub.map(d => d.set))) {
const subset = sub.filter(d => d.set.isSameSet(exSet)) const subset = sub.filter(d => d.set.isSameSet(exSet))
for (mol of uniq(subset.map(d => d.molecule))) { for (mol of uniq(subset.map(d => d.molecule))) {
const submol = subset.filter(d => d.molecule === mol) const submol = subset.filter(d => d.molecule === mol)
const source = await submol.findAsync(async (d) => { const source = submol.find((d) => {
if (await d.set.getDOIAsync() === "10.1021/acs.jctc.8b01205") { if (db.sets.get(d.set.name)[d.set.index] === "10.1021/acs.jctc.8b01205") {
return d.method.name === "CASPT2" && d.method.basis === "aug-cc-pVDZ" return d.method.name === "CASPT2" && d.method.basis === "aug-cc-pVDZ"
} else { } else {
return d.method.isTBE return d.method.isTBE

View File

@ -6,9 +6,8 @@ class Geometry {
static async loadXYZAsync(file) { static async loadXYZAsync(file) {
switch (trueTypeOf(file)) { switch (trueTypeOf(file)) {
case String.name: case String.name:
file = getFullDataPath("/structures/"+file) file = getFullDataPath("structures"+file)
const maxAge= (DebugMode.Enabled,0,600) var str = getTextFromFileUrl(file)
var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`})
break; break;
case File.name: case File.name:
var str = await getTextFromUploadedFileAsync(file) var str = await getTextFromUploadedFileAsync(file)

View File

@ -261,17 +261,20 @@ class dataFileBase {
}) })
} }
CopyExcitationsTypeFrom(data) { CopyExcitationsTypeFrom(data) {
var exc_strings = data.excitations.map( e => [e, JSON.stringify(e.initial), JSON.stringify(e.final) ] )
for (const ex of this.excitations) { for (const ex of this.excitations) {
const ex2 = data.excitations.find((e) => { const exi = JSON.stringify(ex.initial)
return (JSON.stringify(e.initial) === JSON.stringify(ex.initial)) && (JSON.stringify(e.final) === JSON.stringify(ex.final)) const exf = JSON.stringify(ex.final)
const ex2 = exc_strings.find((e) => {
return (e[1]=== exi) && (e[2]=== exf)
}) })
if (ex2 !== undefined) { if (ex2 !== undefined) {
if (DebugMode.Enabled) { if (DebugMode.Enabled) {
const restflag=ex.type.Value & ex2.type.Value const restflag=ex.type.Value & ex2[0].type.Value
const result=restflag==ex.type.Value const result=restflag==ex.type.Value
console.assert(result, "Excitation type error", data.molecule, ex, ex2, this.sourceFile) console.assert(result, "Excitation type error", data.molecule, ex, ex2[0], this.sourceFile)
} }
ex.type = ex2.type ex.type = ex2[0].type
} }
} }
} }
@ -279,9 +282,9 @@ class dataFileBase {
switch (trueTypeOf(file)) { switch (trueTypeOf(file)) {
case String.name: case String.name:
file = getFullDataPath(file) file = getFullDataPath(file)
const maxAge= (DebugMode.Enabled,0,600) // const maxAge= (DebugMode.Enabled,0,600)
// var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`}) // var str = await getTextFromFileUrlAsync(file,{"Cache-Control":`max-age=${maxAge}`})
var str = await getTextFromFileUrl(file) var str = getTextFromFileUrl(file)
break; break;
case File.name: case File.name:
var str = await getTextFromUploadedFileAsync(file) var str = await getTextFromUploadedFileAsync(file)
@ -291,6 +294,20 @@ class dataFileBase {
dat.sourceFile = new websiteFile(file) dat.sourceFile = new websiteFile(file)
return dat return dat
} }
static load(file, kind = undefined) {
switch (trueTypeOf(file)) {
case String.name:
file = getFullDataPath(file)
var str = getTextFromFileUrl(file)
break;
case File.name:
var str = (async () => await getTextFromUploadedFileAsync(file))().then(x=>x)
break
}
var dat = this.loadString(str, kind);
dat.sourceFile = new websiteFile(file)
return dat
}
_OnReadMetaPair(key, value) { _OnReadMetaPair(key, value) {
switch (key) { switch (key) {
case "molecule": case "molecule":

View File

@ -4,10 +4,10 @@ async function loadAllData() {
fluo: [], fluo: [],
}; };
for (const f of getAbsFilesName()) { for (const f of getAbsFilesName()) {
dic.abs.push(await VertDataFile.loadAsync(f,VertExcitationKinds.Absorbtion)) dic.abs.push(VertDataFile.load(f,VertExcitationKinds.Absorbtion))
} }
for (const f of getFluoFilesName()) { for (const f of getFluoFilesName()) {
dic.fluo.push(await VertDataFile.loadAsync(f,VertExcitationKinds.Fluorescence)) dic.fluo.push(VertDataFile.load(f,VertExcitationKinds.Fluorescence))
} }
return dic; return dic;
} }

View File

@ -1,8 +1,11 @@
function uniq(array) function uniq(array)
{ {
return uniqueArray = array.filter((obj1,index) => { if (array.length == 0) return [];
return index === array.findIndex(obj2 => { const sortedArray = array.sort().map( x => [x, JSON.stringify(x)] );
return JSON.stringify(obj1) === JSON.stringify(obj2); var uniqueArray = [ sortedArray[0][0] ];
}); for (let i=1 ; i<sortedArray.length ; i++) {
}); if ( sortedArray[i][1] != sortedArray[i-1][1])
uniqueArray.push(sortedArray[i][0])
}
return uniqueArray;
} }