Skip to content
Snippets Groups Projects
Commit 3926d651 authored by Quentin Bramas's avatar Quentin Bramas
Browse files

new db version with years

parent dc0f9c75
Branches
Tags
No related merge requests found
Pipeline #94589 passed with stage
in 5 minutes and 45 seconds
No preview for this file type
2
\ No newline at end of file
......@@ -8,11 +8,30 @@ import fs from 'fs'
let _db:sqlite.Database<sqlite3.Database, sqlite3.Statement> = null;
const dbPath = process.env.DATA_PATH || '/data/db.sqlite';
const dataPath = process.env.DATA_PATH || '/data';
const dbPath = dataPath+'/db.sqlite';
const dbVersionPath = dataPath+'/db.version';
export async function init() {
// Check the version of the database
const res = await fetch('https://git.unistra.fr/bramas/s-rank/-/raw/master/db.version');
if (!res.ok)
{
console.log(res);
throw new Error('Cannot fetch db version form https://git.unistra.fr/bramas/s-rank/-/raw/master/db.version');
}
const version = await res.text();
let need_download = false;
if(!fs.existsSync(dbVersionPath) || fs.readFileSync(dbVersionPath, 'utf8').trim() != version.trim()) {
need_download = true;
fs.writeFileSync(dbVersionPath, version);
}
// check if the db file exists
if(!fs.existsSync(dbPath)) {
if(!fs.existsSync(dbPath) || need_download) {
console.log('Downloading the database file');
try {
const file = fs.createWriteStream(dbPath);
......
......@@ -24,14 +24,31 @@ const initRanks = async () => {
console.log('Initializing predefined community ranks');
const from_year = 2022 - 6;
for(const pc of Object.values(predefinedCommunities))
{
console.log('Initializing', pc);
try{
if(pc.query.startsWith('author_id'))
{
const journals = await db().all<Row[]>('select V.id, V.name, V.key, V.fullname, SUM(AV.contrib) as score from authors_journals as AV LEFT JOIN journals as V ON (AV.venue_id = V.id) WHERE AV.'+pc.query+' GROUP BY V.id ORDER BY score DESC');
const conferences = await db().all<Row[]>('select V.id, V.name, V.key, V.fullname, SUM(AV.contrib) as score from authors_conferences as AV LEFT JOIN conferences as V ON (AV.venue_id = V.id) WHERE AV.'+pc.query+' GROUP BY V.id ORDER BY score DESC');
const q = pc.query.replaceAll(':from_year', from_year.toString());
const journals = await db().all<Row[]>(`
SELECT _V.id, _V.name, SUM(_AV.contrib) as score
FROM authors_journals as _AV
LEFT JOIN journals as _V ON (_AV.venue_id = _V.id)
WHERE _AV.year >= ${from_year}
AND _AV.${q}
GROUP BY _V.id ORDER by score DESC`);
const conferences = await db().all<Row[]>(`
SELECT _V.id, _V.name, SUM(_AV.contrib) as score
FROM authors_conferences as _AV
LEFT JOIN conferences as _V ON (_AV.venue_id = _V.id)
WHERE _AV.year >= ${from_year}
AND _AV.${q}
GROUP BY _V.id ORDER by score DESC`);
predefinedCommunityRanks[pc.slug] = {
journals: journals.map((c,i) => ({...c, rank: i+1})),
conferences: conferences.map((c,i) => ({...c, rank: i+1}))
......
......@@ -9,12 +9,12 @@ export default {
dist: {
slug: 'dist',
name: 'Distributed Computing',
query: 'author_id IN (SELECT AV.author_id FROM authors_conferences AS AV INNER JOIN conferences AS V ON AV.venue_id = V.id WHERE V.name IN ("DISC", "PODC", "OPODIS", "SIROCCO"))'
query: 'author_id IN (SELECT AV.author_id FROM authors_conferences as AV INNER JOIN conferences as V ON AV.venue_id = V.id WHERE AV.year >= :from_year AND V.name IN ("DISC", "PODC", "OPODIS", "SIROCCO") GROUP BY AV.author_id)'
},
network: {
slug: 'network',
name: 'Networking',
query: 'author_id IN (SELECT AV.author_id FROM authors_conferences AS AV INNER JOIN conferences AS V ON AV.venue_id = V.id WHERE V.name IN ("SIGCOMM", "CoNEXT"))'
query: 'author_id IN (SELECT AV.author_id FROM authors_conferences as AV INNER JOIN conferences as V ON AV.venue_id = V.id WHERE AV.year >= :from_year AND V.name IN ("SIGCOMM", "CoNEXT") GROUP BY AV.author_id)'
},
algotel:{
slug: 'algotel',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment