changeset 100:f52a4c112d79

Recording two card edit timestamps, one for user and one internal
author Fox
date Wed, 05 Apr 2023 21:55:08 +0200
parents 40f1ea8f49ef
children 50af17182cd8
files src/junotu/Card.java src/junotu/ColumnCardWidget.java src/junotu/Database.java src/junotu/TabBoard.java src/junotu/TabCalendarBoard.java src/junotu/TabEdit.java
diffstat 6 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
diff -r 40f1ea8f49ef -r f52a4c112d79 src/junotu/Card.java
--- a/src/junotu/Card.java	Wed Apr 05 21:36:27 2023 +0200
+++ b/src/junotu/Card.java	Wed Apr 05 21:55:08 2023 +0200
@@ -15,6 +15,7 @@
     public static final String TAG_TITLE       = TAG_CORE_PREFIX+"title";
     public static final String TAG_CONTENT     = TAG_CORE_PREFIX+"content";
     public static final String TAG_SEARCH      = TAG_CORE_PREFIX+"search";
+    public static final String TAG_SAVED       = TAG_CORE_PREFIX+"timestamp_saved";
     public static final String TAG_LAST_EDIT   = TAG_CORE_PREFIX+"timestamp_last_edit";
     
     public static final String TAG_BOARD              = TAG_CORE_PREFIX+"board";
diff -r 40f1ea8f49ef -r f52a4c112d79 src/junotu/ColumnCardWidget.java
--- a/src/junotu/ColumnCardWidget.java	Wed Apr 05 21:36:27 2023 +0200
+++ b/src/junotu/ColumnCardWidget.java	Wed Apr 05 21:55:08 2023 +0200
@@ -88,7 +88,7 @@
 		}
 		
 		card.titleSet( title.getText() );
-		Main.database.cardUpdate(card);
+		Main.database.cardUpdate( card, true );
 		
 	    }
 	} catch( Exception e ) {
diff -r 40f1ea8f49ef -r f52a4c112d79 src/junotu/Database.java
--- a/src/junotu/Database.java	Wed Apr 05 21:36:27 2023 +0200
+++ b/src/junotu/Database.java	Wed Apr 05 21:55:08 2023 +0200
@@ -117,9 +117,7 @@
 	    for( int i = 0; i < topDocuments.scoreDocs.length; i++ ) {
 		Document document = luceneSearcher.doc( topDocuments.scoreDocs[i].doc );
 		card = cardFromDocument( document );
-		Query query = NumericRangeQuery.newLongRange( Card.TAG_IDENTIFIER, card.identifierGet(), card.identifierGet(), true, true );
-	        luceneWriter.deleteDocuments( query );
-		luceneWriter.addDocument( cardToDocument( card ) );
+	        cardUpdate( card, false );
 	    }
 
 	    searcherRefresh();
@@ -127,6 +125,7 @@
 	} catch( IOException e ) {
 	    throw new RuntimeException(e);
 	}
+	System.out.print("Database: finished resaving all cards.\n");
     }
 
     private void searcherRefresh()
@@ -243,7 +242,7 @@
 	
     }
 
-    public void cardUpdate( Card card )
+    public void cardUpdate( Card card, boolean userEdit )
     {
 
 	TopDocs topDocuments;
@@ -258,7 +257,10 @@
 	    throw new RuntimeException( "Failed to update card with identifier "+Long.toString( card.identifierGet() )+", not found." );
 	}
 
-	card.tagValueSetOnly( Card.TAG_LAST_EDIT, new Long( System.currentTimeMillis() ) );
+	card.tagValueSetOnly( Card.TAG_SAVED, new Long( System.currentTimeMillis() ) );
+	if( userEdit ) {
+	    card.tagValueSetOnly( Card.TAG_LAST_EDIT, new Long( System.currentTimeMillis() ) );
+	}
 	
         int documentNumber = topDocuments.scoreDocs[0].doc;
 
diff -r 40f1ea8f49ef -r f52a4c112d79 src/junotu/TabBoard.java
--- a/src/junotu/TabBoard.java	Wed Apr 05 21:36:27 2023 +0200
+++ b/src/junotu/TabBoard.java	Wed Apr 05 21:55:08 2023 +0200
@@ -348,7 +348,7 @@
 		    identifier = Main.database.cardAdd( card );
 		    newCard = false;
 		} else {
-		    Main.database.cardUpdate(card);
+		    Main.database.cardUpdate( card, false );
 		}
 	    } catch( Exception e ) {
 		throw new RuntimeException(e);
@@ -527,7 +527,7 @@
 	    card.tagRemove( Card.TAG_BOARD_COLUMNS );
 	}
 
-	Main.database.cardUpdate(card);
+	Main.database.cardUpdate( card, true );
 	Main.refreshSearches();
 	
 	return card;
diff -r 40f1ea8f49ef -r f52a4c112d79 src/junotu/TabCalendarBoard.java
--- a/src/junotu/TabCalendarBoard.java	Wed Apr 05 21:36:27 2023 +0200
+++ b/src/junotu/TabCalendarBoard.java	Wed Apr 05 21:55:08 2023 +0200
@@ -346,7 +346,7 @@
 		    identifier = Main.database.cardAdd( card );
 		    newCard = false;
 		} else {
-		    Main.database.cardUpdate(card);
+		    Main.database.cardUpdate( card, false );
 		}
 	    } catch( Exception e ) {
 		throw new RuntimeException(e);
@@ -559,7 +559,7 @@
 	    column.save();
 	}
 
-	Main.database.cardUpdate(card);
+	Main.database.cardUpdate( card, true );
 	Main.refreshSearches();
 	
 	return card;
diff -r 40f1ea8f49ef -r f52a4c112d79 src/junotu/TabEdit.java
--- a/src/junotu/TabEdit.java	Wed Apr 05 21:36:27 2023 +0200
+++ b/src/junotu/TabEdit.java	Wed Apr 05 21:55:08 2023 +0200
@@ -511,7 +511,7 @@
 	if( newCard ) {
 	    Main.database.cardAdd( card );
 	} else {
-	    Main.database.cardUpdate( card );
+	    Main.database.cardUpdate( card, true );
 	}
 
 	Main.refreshSearches();