Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy retry #325

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/vue/src/SkldrVue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue from 'vue';
import { Store } from 'vuex';
import { AppState } from '@/store';
import { AppState } from './store';
import { User } from './db/userDB';

export default class SkldrVue extends Vue {
Expand All @@ -17,7 +17,7 @@ export default class SkldrVue extends Vue {
/**
* Print an error message to the console. Prefixes the message with the
* component name.
<<<<<<< HEAD
*
* @param message
*/
protected error(message?: any, ...optionalParams: any[]): void {
Expand Down
29 changes: 28 additions & 1 deletion packages/vue/src/base-course/Viewable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SkldrVue from '../SkldrVue';
/**
* Base class for card views in courses.
*/
export default abstract class Viewable extends SkldrVue implements Vue {
export default abstract class Viewable extends Vue {
@Prop() public data: ViewData[];
public toString(): string {
this.warn('toString() not implemented');
Expand All @@ -20,6 +20,33 @@ export default abstract class Viewable extends SkldrVue implements Vue {
protected MouseTrap = new MouseTrap(this.$el);
public hotKeys: HotKey[] = [];

/**
* Print a message to the console. Prefixes the message with the component
* name.
*/
protected log(message?: any, ...optionalParams: any[]): void {
console.log(`[V.${this.$options.name}]: `, message, ...optionalParams);
}

/**
* Print an error message to the console. Prefixes the message with the
* component name.
*
* @param message
*/
protected error(message?: any, ...optionalParams: any[]): void {
console.error(`[V.${this.$options.name}]: `, message, ...optionalParams);
}

/**
* Print a warning message to the console. Prefixes the message with the
* component name.
* @param message
*/
protected warn(message?: any, ...optionalParams: any[]): void {
console.warn(`[V.${this.$options.name}]: `, message, ...optionalParams);
}

/**
* Returns the time in milliseconds since the element was created
*/
Expand Down
56 changes: 28 additions & 28 deletions packages/vue/src/db/courseDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class CourseDB implements StudyContentSource {

// this.log()
const newCards = (await this.getCardsByELO(EloToNumber(userCrsdoc!.elo), cardLimit)).filter(
(card) => {
card => {
return activeCards.indexOf(card) === -1;
}
);
Expand All @@ -65,7 +65,7 @@ export class CourseDB implements StudyContentSource {
u.getCourseRegDoc(this.id);

const reviews = await u.getPendingReviews(this.id); // todo: this adds a db round trip - should be server side
const elo = await this.getCardEloData(reviews.map((r) => r.cardId));
const elo = await this.getCardEloData(reviews.map(r => r.cardId));

const ratedReviews = reviews.map((r, i) => {
const ratedR: ratedReview = {
Expand All @@ -79,7 +79,7 @@ export class CourseDB implements StudyContentSource {
return a.global.score - b.global.score;
});

return ratedReviews.map((r) => {
return ratedReviews.map(r => {
return {
...r,
contentSourceType: 'course',
Expand All @@ -98,7 +98,7 @@ export class CourseDB implements StudyContentSource {
await this.db.query('cardsByInexperience', {
limit,
})
).rows.map((r) => {
).rows.map(r => {
const ret = {
courseId: this.id,
cardId: r.id,
Expand All @@ -116,11 +116,11 @@ export class CourseDB implements StudyContentSource {
limit: number;
page: number;
} = {
low: 0,
high: Number.MIN_SAFE_INTEGER,
limit: 25,
page: 0,
}
low: 0,
high: Number.MIN_SAFE_INTEGER,
limit: 25,
page: 0,
}
) {
return (
await this.db.query('elo', {
Expand All @@ -129,7 +129,7 @@ export class CourseDB implements StudyContentSource {
limit: options.limit,
skip: options.limit * options.page,
})
).rows.map((r) => {
).rows.map(r => {
return `${this.id}-${r.id}-${r.key}`;
});
}
Expand All @@ -139,7 +139,7 @@ export class CourseDB implements StudyContentSource {
include_docs: true,
});
let ret: CourseElo[] = [];
docs.rows.forEach((r) => {
docs.rows.forEach(r => {
if (r.doc && r.doc.elo) {
ret.push(toCourseElo(r.doc.elo));
} else {
Expand Down Expand Up @@ -193,12 +193,12 @@ export class CourseDB implements StudyContentSource {
include_docs: true,
});
let ret: { [card: string]: string[] } = {};
cards.rows.forEach((r) => {
cards.rows.forEach(r => {
ret[r.id] = r.doc!.id_displayable_data;
});

await Promise.all(
cards.rows.map((r) => {
cards.rows.map(r => {
return async () => {
ret[r.id] = r.doc!.id_displayable_data;
};
Expand All @@ -213,9 +213,9 @@ export class CourseDB implements StudyContentSource {
limit: number;
elo: 'user' | 'random' | number;
} = {
limit: 99,
elo: 'user',
},
limit: 99,
elo: 'user',
},
filter?: (a: string) => boolean
): Promise<StudySessionItem[]> {
let targetElo: number;
Expand All @@ -225,7 +225,7 @@ export class CourseDB implements StudyContentSource {

targetElo = -1;
try {
const courseDoc = (await u.getCourseRegistrationsDoc()).courses.find((c) => {
const courseDoc = (await u.getCourseRegistrationsDoc()).courses.find(c => {
return c.courseID === this.id;
})!;
targetElo = EloToNumber(courseDoc.elo);
Expand Down Expand Up @@ -268,7 +268,7 @@ export class CourseDB implements StudyContentSource {
selectedCards.push(card);
}

return selectedCards.map((c) => {
return selectedCards.map(c => {
const split = c.split('-');
return {
courseID: this.id,
Expand All @@ -286,13 +286,13 @@ export class CourseDB implements StudyContentSource {
const activeCards = await u.getActiveCards(this.id);
return (
await this.getCardsCenteredAtELO({ limit: limit, elo: 'user' }, (c: string) => {
if (activeCards.some((ac) => c.includes(ac))) {
if (activeCards.some(ac => c.includes(ac))) {
return false;
} else {
return true;
}
})
).map((c) => {
).map(c => {
return {
...c,
status: 'new',
Expand Down Expand Up @@ -332,11 +332,11 @@ export class CourseDB implements StudyContentSource {
return s;
}
})
.map((c) => `${this.id}-${c.id}-${c.key}`);
.map(c => `${this.id}-${c.id}-${c.key}`);

const str = `below:\n${below.rows.map((r) => `\t${r.id}-${r.key}\n`)}
const str = `below:\n${below.rows.map(r => `\t${r.id}-${r.key}\n`)}

above:\n${above.rows.map((r) => `\t${r.id}-${r.key}\n`)}`;
above:\n${above.rows.map(r => `\t${r.id}-${r.key}\n`)}`;

this.log(`Getting ${limit} cards centered around elo: ${elo}:\n\n` + str);

Expand All @@ -357,7 +357,7 @@ export async function getCourseName(courseID: string): Promise<string> {
}

export async function removeCourse(courseID: string) {
return courseLookupDB.get(courseID).then((course) => {
return courseLookupDB.get(courseID).then(course => {
return courseLookupDB.remove({
...course,
});
Expand All @@ -370,7 +370,7 @@ export async function disambiguateCourse(course: string, disambiguator: string)
// directly impaact the running of the course itself

// write to the lookup db
courseLookupDB.get<CourseConfig>(course).then((cfg) => {
courseLookupDB.get<CourseConfig>(course).then(cfg => {
courseLookupDB.put({
...cfg,
disambiguator,
Expand All @@ -383,7 +383,7 @@ export async function getCachedCourseList(): Promise<CourseConfig[]> {
if (courseListCache.length) {
return courseListCache;
} else {
courseListCache = (await getCourseList()).rows.map((r) => {
courseListCache = (await getCourseList()).rows.map(r => {
return {
...r.doc!,
courseID: r.id,
Expand Down Expand Up @@ -438,7 +438,7 @@ export async function getCourseTagStubs(
DocType.TAG.valueOf() + '-'
);

stubs.rows.forEach((row) => {
stubs.rows.forEach(row => {
log(`\tTag stub for doc: ${row.id}`);
});

Expand Down Expand Up @@ -489,7 +489,7 @@ export async function removeTagFromCard(courseID: string, cardID: string, tagID:
tagID = getTagID(tagID);
const courseDB = getCourseDB(courseID);
const tag = await courseDB.get<Tag>(tagID);
_.remove(tag.taggedCards, (taggedID) => {
_.remove(tag.taggedCards, taggedID => {
return cardID === taggedID;
});
return courseDB.put<Tag>(tag);
Expand Down
Loading