Skip to content

Commit 48e9dd0

Browse files
committed
Remove standalone increment_version methods
Remove `increment_version_by_list_metadata_id` and `increment_version_by_list_key` since version increment should only happen through `get_or_create_and_increment_version` as part of a proper refresh flow, not called arbitrarily.
1 parent cb2f187 commit 48e9dd0

File tree

1 file changed

+0
-72
lines changed

1 file changed

+0
-72
lines changed

wp_mobile_cache/src/repository/list_metadata.rs

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -435,41 +435,6 @@ impl ListMetadataRepository {
435435
Self::update_state_by_list_metadata_id(executor, list_metadata_id, state, error_message)
436436
}
437437

438-
/// Increment version by ID and return the new value.
439-
///
440-
/// Used when starting a refresh to invalidate any in-flight load-more operations.
441-
pub fn increment_version_by_list_metadata_id(
442-
executor: &impl QueryExecutor,
443-
list_metadata_id: RowId,
444-
) -> Result<i64, SqliteDbError> {
445-
let sql = format!(
446-
"UPDATE {} SET version = version + 1, last_first_page_fetched_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now') WHERE rowid = ?",
447-
Self::header_table().table_name()
448-
);
449-
executor.execute(&sql, rusqlite::params![list_metadata_id])?;
450-
451-
// Return the new version
452-
let sql = format!(
453-
"SELECT version FROM {} WHERE rowid = ?",
454-
Self::header_table().table_name()
455-
);
456-
let mut stmt = executor.prepare(&sql)?;
457-
stmt.query_row(rusqlite::params![list_metadata_id], |row| row.get(0))
458-
.map_err(SqliteDbError::from)
459-
}
460-
461-
/// Increment version by site and key and return the new value.
462-
///
463-
/// If you already have the `list_metadata_id`, use `increment_version_by_list_metadata_id` instead.
464-
pub fn increment_version_by_list_key(
465-
executor: &impl QueryExecutor,
466-
site: &DbSite,
467-
key: &ListKey,
468-
) -> Result<i64, SqliteDbError> {
469-
let list_metadata_id = Self::get_or_create(executor, site, key)?;
470-
Self::increment_version_by_list_metadata_id(executor, list_metadata_id)
471-
}
472-
473438
/// Delete all data for a list (header, items, and state).
474439
pub fn delete_list(
475440
executor: &impl QueryExecutor,
@@ -1126,43 +1091,6 @@ mod tests {
11261091
assert_eq!(state, ListState::FetchingNextPage);
11271092
}
11281093

1129-
#[rstest]
1130-
fn test_increment_version(test_ctx: TestContext) {
1131-
let key = ListKey::from("edit:posts:publish");
1132-
1133-
// Create header (version starts at 0)
1134-
ListMetadataRepository::get_or_create(&test_ctx.conn, &test_ctx.site, &key)
1135-
.expect("should succeed");
1136-
let initial_version =
1137-
ListMetadataRepository::get_version(&test_ctx.conn, &test_ctx.site, &key)
1138-
.expect("should succeed");
1139-
assert_eq!(initial_version, 0);
1140-
1141-
// Increment version
1142-
let new_version = ListMetadataRepository::increment_version_by_list_key(
1143-
&test_ctx.conn,
1144-
&test_ctx.site,
1145-
&key,
1146-
)
1147-
.expect("should succeed");
1148-
assert_eq!(new_version, 1);
1149-
1150-
// Increment again
1151-
let newer_version = ListMetadataRepository::increment_version_by_list_key(
1152-
&test_ctx.conn,
1153-
&test_ctx.site,
1154-
&key,
1155-
)
1156-
.expect("should succeed");
1157-
assert_eq!(newer_version, 2);
1158-
1159-
// Verify last_first_page_fetched_at is set
1160-
let header = ListMetadataRepository::get_header(&test_ctx.conn, &test_ctx.site, &key)
1161-
.expect("query should succeed")
1162-
.expect("should succeed");
1163-
assert!(header.last_first_page_fetched_at.is_some());
1164-
}
1165-
11661094
#[rstest]
11671095
fn test_get_or_create_and_increment_version_creates_new(test_ctx: TestContext) {
11681096
let key = ListKey::from("edit:posts:new");

0 commit comments

Comments
 (0)