mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +00:00
Schema 22, strip out last_suggested_nip23 (we never processed nip23, and contact list relay data is now processed like kind 10002)
This commit is contained in:
parent
fd44d09c0e
commit
9a0868d91c
@ -103,7 +103,7 @@ macro_rules! apply_sql {
|
||||
}
|
||||
|
||||
fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> {
|
||||
let current_version = 21;
|
||||
let current_version = 22;
|
||||
if version > current_version {
|
||||
panic!(
|
||||
"Database version {} is newer than this binary which expects version {}.",
|
||||
@ -134,6 +134,7 @@ fn upgrade(db: &Connection, mut version: u16) -> Result<(), Error> {
|
||||
apply_sql!(db, version, 19, "schema19.sql");
|
||||
apply_sql!(db, version, 20, "schema20.sql");
|
||||
apply_sql!(db, version, 21, "schema21.sql");
|
||||
apply_sql!(db, version, 22, "schema22.sql");
|
||||
tracing::info!("Database is at version {}", version);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ pub struct DbPersonRelay {
|
||||
pub last_fetched: Option<u64>,
|
||||
pub last_suggested_kind2: Option<u64>,
|
||||
pub last_suggested_kind3: Option<u64>,
|
||||
pub last_suggested_nip23: Option<u64>,
|
||||
pub last_suggested_nip05: Option<u64>,
|
||||
pub last_suggested_bytag: Option<u64>,
|
||||
pub read: bool,
|
||||
@ -32,14 +31,14 @@ impl DbPersonRelay {
|
||||
|
||||
let sql = format!(
|
||||
"SELECT person, relay, person_relay.last_fetched, \
|
||||
last_suggested_kind2, last_suggested_kind3, last_suggested_nip23, \
|
||||
last_suggested_kind2, last_suggested_kind3, \
|
||||
last_suggested_nip05, last_suggested_bytag, \
|
||||
person_relay.read, person_relay.write \
|
||||
FROM person_relay \
|
||||
INNER JOIN relay ON person_relay.relay=relay.url \
|
||||
WHERE person IN ({}) ORDER BY person, \
|
||||
person_relay.write DESC, relay.rank DESC, \
|
||||
last_suggested_nip23 DESC, last_suggested_kind3 DESC, \
|
||||
last_suggested_kind3 DESC, \
|
||||
last_suggested_nip05 DESC, last_suggested_kind2 DESC, \
|
||||
last_fetched DESC, last_suggested_bytag DESC",
|
||||
repeat_vars(pubkeys.len())
|
||||
@ -64,11 +63,10 @@ impl DbPersonRelay {
|
||||
last_fetched: row.get(2)?,
|
||||
last_suggested_kind2: row.get(3)?,
|
||||
last_suggested_kind3: row.get(4)?,
|
||||
last_suggested_nip23: row.get(5)?,
|
||||
last_suggested_nip05: row.get(6)?,
|
||||
last_suggested_bytag: row.get(7)?,
|
||||
read: row.get(8)?,
|
||||
write: row.get(9)?,
|
||||
last_suggested_nip05: row.get(5)?,
|
||||
last_suggested_bytag: row.get(6)?,
|
||||
read: row.get(7)?,
|
||||
write: row.get(8)?,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -82,9 +80,9 @@ impl DbPersonRelay {
|
||||
|
||||
pub async fn insert(person_relay: DbPersonRelay) -> Result<(), Error> {
|
||||
let sql = "INSERT OR IGNORE INTO person_relay (person, relay, last_fetched, \
|
||||
last_suggested_kind2, last_suggested_kind3, last_suggested_nip23, \
|
||||
last_suggested_kind2, last_suggested_kind3, \
|
||||
last_suggested_nip05, last_suggested_bytag, read, write) \
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
|
||||
spawn_blocking(move || {
|
||||
let maybe_db = GLOBALS.db.blocking_lock();
|
||||
@ -97,7 +95,6 @@ impl DbPersonRelay {
|
||||
&person_relay.last_fetched,
|
||||
&person_relay.last_suggested_kind2,
|
||||
&person_relay.last_suggested_kind3,
|
||||
&person_relay.last_suggested_nip23,
|
||||
&person_relay.last_suggested_nip05,
|
||||
&person_relay.last_suggested_bytag,
|
||||
&person_relay.read,
|
||||
@ -292,7 +289,7 @@ impl DbPersonRelay {
|
||||
dir: Direction,
|
||||
) -> Result<Vec<(RelayUrl, u64)>, Error> {
|
||||
let sql = "SELECT person, relay, last_fetched, last_suggested_kind2, \
|
||||
last_suggested_kind3, last_suggested_nip23, \
|
||||
last_suggested_kind3, \
|
||||
last_suggested_nip05, last_suggested_bytag, read, write \
|
||||
FROM person_relay WHERE person=?";
|
||||
|
||||
@ -314,11 +311,10 @@ impl DbPersonRelay {
|
||||
last_fetched: row.get(2)?,
|
||||
last_suggested_kind2: row.get(3)?,
|
||||
last_suggested_kind3: row.get(4)?,
|
||||
last_suggested_nip23: row.get(5)?,
|
||||
last_suggested_nip05: row.get(6)?,
|
||||
last_suggested_bytag: row.get(7)?,
|
||||
read: row.get(8)?,
|
||||
write: row.get(9)?,
|
||||
last_suggested_nip05: row.get(5)?,
|
||||
last_suggested_bytag: row.get(6)?,
|
||||
read: row.get(7)?,
|
||||
write: row.get(8)?,
|
||||
};
|
||||
dbprs.push(dbpr);
|
||||
}
|
||||
@ -382,8 +378,6 @@ impl DbPersonRelay {
|
||||
// This is the ranking we are using. There might be reasons
|
||||
// for ranking differently.
|
||||
// write (score=20) [ they claim (to us) ]
|
||||
// nip23 (score=10) [ they say (to themselves) ] [actually kind3 contents]
|
||||
// FIXME, person_relay.last_suggested_nip23 has no direction info
|
||||
// kind3 tag (score=5) [ we say ]
|
||||
// nip05 (score=4) [ they claim, unsigned ]
|
||||
// fetched (score=3) [ we found ]
|
||||
@ -407,12 +401,6 @@ impl DbPersonRelay {
|
||||
score += 20;
|
||||
}
|
||||
|
||||
// nip23 is an author-signed statement to themselves
|
||||
// kind-3 content also substitutes for nip23, this comes from either.
|
||||
if let Some(when) = dbpr.last_suggested_nip23 {
|
||||
score += scorefn(when, 60 * 60 * 24 * 30, 10);
|
||||
}
|
||||
|
||||
// kind3 is our memory of where we are following someone
|
||||
if let Some(when) = dbpr.last_suggested_kind3 {
|
||||
score += scorefn(when, 60 * 60 * 24 * 30, 7);
|
||||
@ -461,8 +449,6 @@ impl DbPersonRelay {
|
||||
// This is the ranking we are using. There might be reasons
|
||||
// for ranking differently.
|
||||
// read (score=20) [ they claim (to us) ]
|
||||
// nip23 (score=10) [ they say (to themselves) ] [actually kind3 contents]
|
||||
// FIXME, person_relay.last_suggested_nip23 has no direction info
|
||||
// kind3 tag (score=5) [ we say ]
|
||||
// nip05 (score=4) [ they claim, unsigned ]
|
||||
// fetched (score=3) [ we found ]
|
||||
@ -486,12 +472,6 @@ impl DbPersonRelay {
|
||||
score += 20;
|
||||
}
|
||||
|
||||
// nip23 is an author-signed statement to themselves
|
||||
// kind-3 content also substitutes for nip23, this comes from either.
|
||||
if let Some(when) = dbpr.last_suggested_nip23 {
|
||||
score += scorefn(when, 60 * 60 * 24 * 30, 10);
|
||||
}
|
||||
|
||||
// kind3 is our memory of where we are following someone
|
||||
if let Some(when) = dbpr.last_suggested_kind3 {
|
||||
score += scorefn(when, 60 * 60 * 24 * 30, 7);
|
||||
|
1
src/db/schema22.sql
Normal file
1
src/db/schema22.sql
Normal file
@ -0,0 +1 @@
|
||||
ALTER TABLE person_relay DROP COLUMN last_suggested_nip23;
|
@ -706,7 +706,6 @@ impl Overlord {
|
||||
last_fetched: None,
|
||||
last_suggested_kind2: None,
|
||||
last_suggested_kind3: Some(now), // consider it our claim in our contact list
|
||||
last_suggested_nip23: None,
|
||||
last_suggested_nip05: None,
|
||||
last_suggested_bytag: None,
|
||||
read: true,
|
||||
|
Loading…
Reference in New Issue
Block a user