10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-24 13:23:40 +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()
}
async function loadFiles() {
const db = await indexDB.loadAsync()
const data = await loadAllData()
processingIndicator.isActive = true
var data = await loadAllData()
window.defaultDats = []
for (const sub of Object.values(data)) {
for (const exSet of uniq(sub.map(d => d.set))) {
const subset = sub.filter(d => d.set.isSameSet(exSet))
for (mol of uniq(subset.map(d => d.molecule))) {
const submol = subset.filter(d => d.molecule === mol)
const source = await submol.findAsync(async (d) => {
if (await d.set.getDOIAsync() === "10.1021/acs.jctc.8b01205") {
const source = submol.find((d) => {
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"
} else {
return d.method.isTBE

View File

@ -6,11 +6,11 @@ class GeometriesLoader{
const myset=item.set.split("#").join("")
try {
const mol=await Geometry.loadXYZAsync(`/${myset}/${mymol}.xyz`)
xyzs.push(mol)
xyzs.push(mol)
} catch (error) {
console.error("Geometry not found",item)
}
}
}
return xyzs.flat()
}
}
}

View File

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

View File

@ -261,17 +261,20 @@ class dataFileBase {
})
}
CopyExcitationsTypeFrom(data) {
var exc_strings = data.excitations.map( e => [e, JSON.stringify(e.initial), JSON.stringify(e.final) ] )
for (const ex of this.excitations) {
const ex2 = data.excitations.find((e) => {
return (JSON.stringify(e.initial) === JSON.stringify(ex.initial)) && (JSON.stringify(e.final) === JSON.stringify(ex.final))
const exi = JSON.stringify(ex.initial)
const exf = JSON.stringify(ex.final)
const ex2 = exc_strings.find((e) => {
return (e[1]=== exi) && (e[2]=== exf)
})
if (ex2 !== undefined) {
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
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)) {
case String.name:
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 getTextFromFileUrl(file)
var str = getTextFromFileUrl(file)
break;
case File.name:
var str = await getTextFromUploadedFileAsync(file)
@ -291,6 +294,20 @@ class dataFileBase {
dat.sourceFile = new websiteFile(file)
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) {
switch (key) {
case "molecule":

View File

@ -4,10 +4,10 @@ async function loadAllData() {
fluo: [],
};
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()) {
dic.fluo.push(await VertDataFile.loadAsync(f,VertExcitationKinds.Fluorescence))
dic.fluo.push(VertDataFile.load(f,VertExcitationKinds.Fluorescence))
}
return dic;
}

View File

@ -1,8 +1,11 @@
function uniq(array)
{
return uniqueArray = array.filter((obj1,index) => {
return index === array.findIndex(obj2 => {
return JSON.stringify(obj1) === JSON.stringify(obj2);
});
});
}
if (array.length == 0) return [];
const sortedArray = array.sort().map( x => [x, JSON.stringify(x)] );
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;
}