Skip to content

Commit

Permalink
genre reciept
Browse files Browse the repository at this point in the history
sharing genre across reciepts in session
  • Loading branch information
Devlin Leonard committed Apr 23, 2024
1 parent 7952a7e commit a175457
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
13 changes: 5 additions & 8 deletions receiptifyv1/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const cors = require('cors');
require('dotenv').config();


const client_id = '792207d6524f4255a1730e478d8b66f6';
const client_secret = 'fd5c90696d984ca7a65a54853f340c70';
const client_id = 'ed86dba0999b415e8c50d26b13fb29f8';
const client_secret = 'f1421f43be4644dca0076e500d9ed0a6';
//const privateKey = fs.readFileSync('AuthKey_A8FKGGUQP3.p8').toString();
const teamId = process.env.teamId;
const keyId = process.env.keyId;
Expand Down Expand Up @@ -258,13 +258,7 @@ async function processFile(filePath, sessionID, col) {
});
const users = [];
var newDB = "";
var first = true;
for await (const line of rl) {
if(first){
newDB += line + "\n";
first = false;
continue;
}
const row = line.split(',');
if (row[2] == sessionID) {
users.push(row[col]);
Expand Down Expand Up @@ -297,6 +291,9 @@ app.get('/callback', function (req, res) {
if (req.cookies[sessionIDString] != null){
sessionID = req.cookies[sessionIDString];
}

//res.sendFile(__dirname + '/public/join.html');


var code = req.query.code || null;
var state = req.query.state || null;
Expand Down
16 changes: 13 additions & 3 deletions receiptifyv1/public/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,18 @@ function getTopGenres(artists) {
genreArr.sort(function (first, second) {
return second.duration_ms - first.duration_ms;
});
let totalTime = 0;
for(let i = 0; i < 10; i++){
console.log("helloe");
totalTime += genreArr[i].duration_ms;
}
for(let i = 0; i < 10; i++){
genreArr[i].duration_ms = genreArr[i].duration_ms * (100 / totalTime);
}
return genreArr.slice(0, 10);
}


const removeTrack = (i) => {
console.log(i);
if (i >= 0 && i < customReceipt.length) {
Expand Down Expand Up @@ -1042,7 +1051,7 @@ function retrieveItems(stats, state) {
const timeRangeSlug = getPeriod();
const limit = num;

if ( type === 'artists') {
if ( type === 'artists' || type === 'genres') {
const promises = [];
let combined = [];
const timeRangeSlug = "short_term";
Expand Down Expand Up @@ -1091,7 +1100,7 @@ function retrieveItems(stats, state) {
console.error('Errors:', errors); // Handle any errors
});
}

/*
if (type === 'genres') {
$.ajax({
url: `${SPOTIFY_ROOT}/me/top/artists?limit=49&time_range=${timeRangeSlug}`,
Expand All @@ -1117,7 +1126,8 @@ function retrieveItems(stats, state) {
},
});
//console.log(item);
} //else { // shows tracks
}*/
//} //else { // shows tracks
else if(type === 'tracks'){
//console.log('ajax call else');
$.ajax({
Expand Down
3 changes: 0 additions & 3 deletions receiptifyv1/users.csv
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@

Ari,BQA8fwaaWA87EUZvia5emYjOq0IyC0_9rePt7Dsnvs6shbeWFRssWwAfsHYvJAbtnYxDO9vi1YRYs7WUXsd6yzX1UgQE9wMgAJ_VksmJThckhV5qVbQG-Z4zG64YVEHNodfeQoTPWvgCEgC4Rjnb5aWphBYHKcBpseuMAERYqeWxxvWerddgmS22u4D0lpiyqTpKaKzbeiRaY-IuhhzrZfFv8hCSJM1dfPVpUXmTIJ2GkC2_GphugfE6,763656,1713334863450,
Ari,BQBP9W-1YdtEPiN84p4PnEXDc658wfuhYs2LsCMNm9mR3c2HGjVGTMmQHG5fSxYJVRhPE995RPlGXrx8tZlbux2YDC1LvBCmoh3ntfgiqKkkOmGoIPAUoV8V0ygebaQDRKD3V_uDuCuhbpSb8NIqwV4KbP8ezBQ3zGmU_vtAtULeNjPTbc-QGXK38tOj9M8bBUPQOBqGJkG_HbQqOcd0POBQmNk3OeDdhDOzYcqnZtF5b6y-LMjFJXOm,763656,1713334879131,

0 comments on commit a175457

Please sign in to comment.