Closed DevGareth closed 5 years ago
Also a note, I still kind of think tag should be linked to userID. Otherwise can't get their top used tags - only universally top-used tags which isn't helpful for making a graph.
`for tag in tags: tag_id = tag['tagID']
tag_count = cur.execute("SELECT * FROM Photo_Tag WHERE photoID in (SELECT photoID FROM Photo WHERE userID=%s) AND tagID=%s", (user_id, tag_id))`
Above gets the tag count for one user.
I will work on the below now. Should the 'Get Tags in desc order' be for one user or global? @DevGareth
I don't know really, depends how we want to do tags graphs.
We probably want to display to the user a list of buttons for each of their tags used in the time period. Then show the regular overall graphs specific to that tag.
So we would want local to user and over a time period: tags in descending order of usage.
And local to user and over a time period given a tag: regular data.
Tag usage could be a good graph for admin too actually.
Understood, will work on it now.
Done "over a time period: tags in descending order of usage". Below an example of the fetch call. It returns an array of tags with (tagID, name, count) in desc order.
let basedOn = "tagUsage";
let startDate = "28/04/2019";
let endDate = "29/04/2019"; // exclusive
let authToken = localStorage.getItem("authToken");
fetch(apiMoodportfolio + '/EmotionsQuery', {
method: "GET",
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
headers: {
"Authorization": authToken,
"Content-Type": "application/json",
"BasedOn": basedOn,
"StartDate": startDate,
"EndDate": endDate,
},
})
.then((res) => res.json())
.then(json => {
console.log('tag emotionsquery', json)
})
.catch(err => console.log(err))
Awesome, I'm thinking a TagSelect component that does that on mount and then we just render as buttons in container. Trying to do nodeviewer atm so will get to that next
Done "local to user and over a time period given a tag: regular data". Below an example of the fetch call. It returns the same data as basedOnAll but basedOnTagName.
let basedOn = "tag";
let tagName = "tag1";
let startDate = "28/04/2019";
let endDate = "29/04/2019"; // exclusive
let authToken = localStorage.getItem("authToken");
fetch(apiMoodportfolio + '/EmotionsQuery', {
method: "GET",
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
headers: {
"Authorization": authToken,
"Content-Type": "application/json",
"BasedOn": basedOn,
"StartDate": startDate,
"EndDate": endDate,
"TagName": tagName,
},
})
.then((res) => res.json())
.then(json => {
console.log('tag ', json)
})
.catch(err => console.log(err))
Can we close this then?
Need to know how we are getting data from the server.
Will it be an api request that we send the tags to? Or the general get which is then searched for tags on frontend?