Merge branch 'main' of https://github.com/mgrove36/parandum into main
This commit is contained in:
@@ -104,11 +104,14 @@ export default withRouter(class GroupStats extends Component {
|
|||||||
if (groupSetIds.length > 0) await this.state.db.collection("incorrect_answers")
|
if (groupSetIds.length > 0) await this.state.db.collection("incorrect_answers")
|
||||||
.where("groups", "array-contains", this.props.match.params.groupId)
|
.where("groups", "array-contains", this.props.match.params.groupId)
|
||||||
.orderBy("term", "asc")
|
.orderBy("term", "asc")
|
||||||
|
.orderBy("definition", "asc")
|
||||||
.get()
|
.get()
|
||||||
.then((querySnapshot) => {
|
.then((querySnapshot) => {
|
||||||
let incorrectAnswers = [];
|
let incorrectAnswers = [];
|
||||||
querySnapshot.docs.map((doc, index, array) => {
|
const docs = querySnapshot.docs
|
||||||
if (doc.data().setIds.some(item => groupSetIds.includes(item))) {
|
.filter((doc) => doc.data().setIds.some(item => groupSetIds.includes(item)));
|
||||||
|
docs
|
||||||
|
.map((doc, index, array) => {
|
||||||
if (index === 0 || doc.data().term !== array[index - 1].data().term || doc.data().definition !== array[index - 1].data().definition) {
|
if (index === 0 || doc.data().term !== array[index - 1].data().term || doc.data().definition !== array[index - 1].data().definition) {
|
||||||
incorrectAnswers.push({
|
incorrectAnswers.push({
|
||||||
term: doc.data().term,
|
term: doc.data().term,
|
||||||
@@ -143,12 +146,10 @@ export default withRouter(class GroupStats extends Component {
|
|||||||
doc.data().setIds.map((setId) => newState.setsWithHistory[setId] = true);
|
doc.data().setIds.map((setId) => newState.setsWithHistory[setId] = true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
newState.incorrectAnswers = incorrectAnswers.sort((a, b) => b.count + b.switchedCount - a.count - a.switchedCount);
|
newState.incorrectAnswers = incorrectAnswers.sort((a, b) => b.count + b.switchedCount - a.count - a.switchedCount);
|
||||||
newState.filteredIncorrectAnswers = newState.incorrectAnswers;
|
newState.filteredIncorrectAnswers = newState.incorrectAnswers;
|
||||||
newState.totalIncorrect = querySnapshot.docs.length;
|
newState.totalIncorrect = docs.length;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
newState.incorrectAnswers = [];
|
newState.incorrectAnswers = [];
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ export default class IncorrectHistory extends Component {
|
|||||||
this.state.db.collection("incorrect_answers")
|
this.state.db.collection("incorrect_answers")
|
||||||
.where("uid", "==", this.state.user.uid)
|
.where("uid", "==", this.state.user.uid)
|
||||||
.orderBy("term", "asc")
|
.orderBy("term", "asc")
|
||||||
|
.orderBy("definition", "asc")
|
||||||
.get()
|
.get()
|
||||||
.then(async (querySnapshot) => {
|
.then(async (querySnapshot) => {
|
||||||
let incorrectAnswers = [];
|
let incorrectAnswers = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user