Skip to content

Commit

Permalink
Add code to generate scores from notion database
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeden committed Mar 15, 2024
1 parent fee2b23 commit 54de86f
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 0 deletions.
3 changes: 3 additions & 0 deletions notion-tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
node_modules
scores.json
30 changes: 30 additions & 0 deletions notion-tools/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require('dotenv').config();
const { Client } = require('@notionhq/client');

const notion = new Client({ auth: process.env.NOTION_API_KEY });

(async () => {
const databaseId = 'aec8e648244c4b42a19d172f9fe9f1aa';
const response = await notion.databases.query({
database_id: databaseId,
sorts: [
{
property: 'BP account',
direction: 'ascending',
},
],
});

let scores = [];

response.results.map(res => {
scores.push({
"guild": res.properties['BP account'].rich_text[0].text.content,
"score": res.properties.Total.number * 10000
});
});

console.log(`${scores.length} guilds were scored`);
console.log(scores);

})();
171 changes: 171 additions & 0 deletions notion-tools/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions notion-tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "notion-tools",
"version": "0.0.1",
"description": "tool to fetch scores from notion database",
"main": "index.js",
"scripts": {
"start": "NODE_ENV=production && node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/wax-office-of-inspector-general/office.git"
},
"author": "rakeden",
"license": "UNLICENSED",
"bugs": {
"url": "https://github.com/wax-office-of-inspector-general/office/issues"
},
"homepage": "https://github.com/wax-office-of-inspector-general/office#readme",
"devDependencies": {
"@notionhq/client": "^2.2.14",
"dotenv": "^16.4.5"
}
}

1 comment on commit 54de86f

@eliasdiek
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rakeden hi ,I'm looking for someone with your stack to work on our platform as a freelancer or full time . some projects start soon and others begin in half a year . are you up ? contact me on telegram @eliasdiek or via email at [email protected]

Please sign in to comment.