After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 684412 - Add support for tagging diary entries
Add support for tagging diary entries
Status: RESOLVED FIXED
Product: almanah
Classification: Other
Component: General
unspecified
Other All
: Normal enhancement
: ---
Assigned To: diary-maint
diary-maint
Depends on:
Blocks:
 
 
Reported: 2012-09-19 23:32 UTC by Philip Withnall
Modified: 2013-09-04 16:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A diary entry with some tags (82.38 KB, image/png)
2013-02-15 10:21 UTC, Álvaro Peña
Details
Diary entry clean window (29.65 KB, image/png)
2013-02-15 10:22 UTC, Álvaro Peña
Details
How looks the tags zone (it can be hidden) (29.23 KB, image/png)
2013-09-04 16:35 UTC, Álvaro Peña
Details

Description Philip Withnall 2012-09-19 23:32:31 UTC
Users might find it useful to be able to add tags to diary entries, to allow them to categorise the entries or make searching easier.

This would behave, e.g., like tagging photos in Shotwell.
Comment 1 marcodefreitas 2012-12-16 22:49:13 UTC
Hashtags like in Tweeter can de useful to make a tag-cloud for search.

@work, @home and #issue, #done, #pending
Comment 2 Álvaro Peña 2013-01-08 09:42:23 UTC
Looks like a good way to append a new tag while your writing. I like it and I'll tray to implement it when all the infrastructure is working.
Comment 3 Álvaro Peña 2013-01-08 10:13:26 UTC
After some discussion about the better way to store the tags in the Almanah database, some tests was realized with two different schemas to take the better decision:

A. Two tables, one for tags and other for the relation between tag and an entry
CREATE TABLE "tags" (
    "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    "tag" TEXT
)
CREATE TABLE "entry_tag" (
    "year" INTEGER, "month" INTEGER, "day" INTEGER,
    "tag_id" INTEGER NOT NULL
)
B. Just one table with this
CREATE TABLE entry_tag (
    "year" INTEGER, "month" INTEGER, "day" INTEGER,
    "tag" TEXT
)

With 1.000 entries (one entry per day in three years) and three tags per entry:

1. Select the entries with a specific tag:
   A: SELECT et.year, et.month, et.day FROM entry_tag et LEFT JOIN tags t ON (t.id = et.tag_id) WHERE t.tag = '%s'; 0.014 s
   B: SELECT year, month, day FROM entry_tag WHERE tag='%s'; 0.018 s
2. Get the tags for an entry:
   A: SELECT t.tag FROM tags t LEFT JOIN entry_tag et ON (t.id = et.tag_id) WHERE et.year=%d AND et.month=%d AND et.day=%d; 0.042 s
   B: SELECT tag FROM entry_tag WHERE year=%d AND month=%d AND day=%d; 0.004 s
3. Get the tags names:
   A: SELECT tag FROM tags; 0.004 s
   B: SELECT DISTINCT tag FROM entry_tag; 0.006 s

There isn't much difference between the two schemes but the second query. So the B scheme it's more simple and handy.
Comment 4 Álvaro Peña 2013-01-08 10:20:12 UTC
Here the schema into src/storage.c (create_tables function)

+		"CREATE TABLE IF NOT EXISTS entry_tag (year INTEGER, month INTEGER, day INTEGER, tag TEXT)", /* added in 0.10.0 */
+		"CREATE INDEX idx_tag ON entry_tag(tag)", /* added in 0.10.0, for information take a look at: http://www.sqlite.org/queryplanner.html */
Comment 5 Álvaro Peña 2013-02-15 10:15:01 UTC
I have pushed to git (master) the code that allow tag diary entries. Required tests and some user feedback, also some thoughts from the design team would be great.
Comment 6 Álvaro Peña 2013-02-15 10:21:37 UTC
Created attachment 236228 [details]
A diary entry with some tags

The "add tag" text is a GtkEntry with an autocompletion list (with all the tags added in the diary). When the user select a tag from the autocompletion list or press "enter" with some text, a tag is added and the focus return to the entry text.
Comment 7 Álvaro Peña 2013-02-15 10:22:37 UTC
Created attachment 236229 [details]
Diary entry clean window

This is the way a clean entry looks.
Comment 8 Philip Withnall 2013-02-16 12:41:05 UTC
Looks great and works nicely from some quick testing! Is it integrated with search yet?
Comment 9 Álvaro Peña 2013-02-25 12:15:07 UTC
(In reply to comment #8)
> ... Is it integrated with
> search yet?

Good point.

I have changed the search query to include the tags like this:

SELECT e.content, e.is_important, e.day, e.month, e.year, e.edited_day, e.edited_month, e.edited_year, e.version, GROUP_CONCAT(et.tag) AS tags FROM entries AS e LEFT JOIN entry_tag AS et ON (e.day=et.day AND e.month=et.month AND e.year=et.year) GROUP BY e.year, e.month, e.day ORDER BY e.year DESC, e.month DESC, e.day DESC

So it's possible to make a "strstr" in order to search the string entered by the user.

I'll commit it ASAP.
Comment 10 Álvaro Peña 2013-09-04 16:34:23 UTC
I have done a "push" with some style and functional changes. I guess this bug can be closed.
Comment 11 Álvaro Peña 2013-09-04 16:35:54 UTC
Created attachment 254108 [details]
How looks the tags zone (it can be hidden)
Comment 12 Álvaro Peña 2013-09-04 16:40:13 UTC
(In reply to comment #1)
> Hashtags like in Tweeter can de useful to make a tag-cloud for search.
> 
> @work, @home and #issue, #done, #pending

I'll close this bug, but opened #707487 to follow your suggestion.