From bdeda3caddf8a7d4defafa9722fde8d4d813eb18 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Fri, 18 Oct 2024 11:23:23 +0800 Subject: [PATCH 1/3] update fsrs-rs to 1.3.3 --- Cargo.lock | 14 +++++++++++++- fsrs-rs | 2 +- src/lib.rs | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d29569d..5cb9dd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -726,7 +726,7 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" [[package]] name = "fsrs" -version = "1.1.4" +version = "1.3.3" dependencies = [ "burn", "chrono", @@ -735,6 +735,7 @@ dependencies = [ "log", "ndarray", "ndarray-rand", + "priority-queue", "rand", "rayon", "serde", @@ -1526,6 +1527,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" +[[package]] +name = "priority-queue" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714c75db297bc88a63783ffc6ab9f830698a6705aa0201416931759ef4c8183d" +dependencies = [ + "autocfg", + "equivalent", + "indexmap", +] + [[package]] name = "proc-macro2" version = "1.0.81" diff --git a/fsrs-rs b/fsrs-rs index ed628b0..8ef7197 160000 --- a/fsrs-rs +++ b/fsrs-rs @@ -1 +1 @@ -Subproject commit ed628b09c5889e870e70c01f89ac1526325583d8 +Subproject commit 8ef7197bec29470cf4ba612e8383f72eb7f4cfb6 diff --git a/src/lib.rs b/src/lib.rs index 0e6d659..7600c71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,7 +131,7 @@ impl FSRSwasm { stability: Option, desired_retention: f32, rating: u32, - ) -> u32 { + ) -> f32 { self.model .next_interval(stability, desired_retention, rating) } From 7c0832663dd5f9777dfb49643605913e98e6bbb9 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Fri, 18 Oct 2024 11:36:47 +0800 Subject: [PATCH 2/3] fix ci --- index.html | 2 +- sandbox/src/App.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 10764c7..5ea5fda 100644 --- a/index.html +++ b/index.html @@ -34,7 +34,7 @@

FSRS Browser Example

const stability = 1.5; // or undefined const desired_retention = 0.9; const rating = 3; - const result = fsrs.nextInterval(stability, desired_retention, rating); + const result = fsrs.nextInterval(stability, desired_retention, rating).toFixed(0); console.log("Next interval:", result); } }); diff --git a/sandbox/src/App.tsx b/sandbox/src/App.tsx index 0791c20..17632e7 100644 --- a/sandbox/src/App.tsx +++ b/sandbox/src/App.tsx @@ -41,7 +41,7 @@ const App: Component = () => { const desired_retention = 0.9 const rating = 3 const fsrs = new Fsrs() - const result = fsrs.nextInterval(stability, desired_retention, rating) + const result = fsrs.nextInterval(stability, desired_retention, rating).toFixed(0) console.log('Next interval:', result) setNextInterval(result.toString()) fsrs.free() // for details grep D91EEC72-FCBC-4140-8ADC-9CF2016A56C5 From ec9326dd26928418638438fc339c694f78e6ac5c Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 18 Oct 2024 17:07:09 -0500 Subject: [PATCH 3/3] loosen test assertion --- index.html | 2 +- sandbox/src/App.tsx | 2 +- sandbox/tests/prod.spec.ts | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 5ea5fda..10764c7 100644 --- a/index.html +++ b/index.html @@ -34,7 +34,7 @@

FSRS Browser Example

const stability = 1.5; // or undefined const desired_retention = 0.9; const rating = 3; - const result = fsrs.nextInterval(stability, desired_retention, rating).toFixed(0); + const result = fsrs.nextInterval(stability, desired_retention, rating); console.log("Next interval:", result); } }); diff --git a/sandbox/src/App.tsx b/sandbox/src/App.tsx index 17632e7..0791c20 100644 --- a/sandbox/src/App.tsx +++ b/sandbox/src/App.tsx @@ -41,7 +41,7 @@ const App: Component = () => { const desired_retention = 0.9 const rating = 3 const fsrs = new Fsrs() - const result = fsrs.nextInterval(stability, desired_retention, rating).toFixed(0) + const result = fsrs.nextInterval(stability, desired_retention, rating) console.log('Next interval:', result) setNextInterval(result.toString()) fsrs.free() // for details grep D91EEC72-FCBC-4140-8ADC-9CF2016A56C5 diff --git a/sandbox/tests/prod.spec.ts b/sandbox/tests/prod.spec.ts index e8e1b13..9502ecb 100644 --- a/sandbox/tests/prod.spec.ts +++ b/sandbox/tests/prod.spec.ts @@ -1,4 +1,4 @@ -import { test, expect, Page } from '@playwright/test' +import { test, expect } from '@playwright/test' import { goHome } from './util' test('check memory state', async ({ page }) => { @@ -22,13 +22,16 @@ test('check memory state', async ({ page }) => { test('check next interval', async ({ page }) => { await goHome(page) await page.getByRole('button', { name: 'Calculate Next Interval' }).click() - await expect(page.locator('#nextIntervalResponse')).toHaveText('2') + await expect(page.locator('#nextIntervalResponse')).toContainText('.') // ensures that text has updated, so the more specific assertion `.toEqual(2)` can run + const nextInterval = await page.locator('#nextIntervalResponse').textContent() + const rounded = Math.round(parseFloat(nextInterval)) + expect(rounded).toEqual(2) }) test('check progress and parameters', async ({ page }) => { await goHome(page) await page.getByRole('button', { name: 'Train with example file' }).click() - let progress = await page.locator('#progressNumbers').innerText() + const progress = await page.locator('#progressNumbers').innerText() expect(progress).toEqual('0/0') await expect .poll(