amuse.git

commit 49200d8b3c116879d05f97bbc670ee288dd3deda

Author: Adam <git@apiote.tk>

show watched episodes in experiences

 datastructure/experiences.go | 1 +
 db/db.go | 7 ++++---
 templates/experiences.html | 12 +++++-------


diff --git a/datastructure/experiences.go b/datastructure/experiences.go
index 0e4c3ff42140f068f8862caa5d3fb7c8f768f797..486faa631d4fe09faf244a86d79632bf5181a34e 100644
--- a/datastructure/experiences.go
+++ b/datastructure/experiences.go
@@ -10,6 +10,7 @@ type ExperiencesEntry struct {
 	ItemInfo
 	Type     string
 	Id       string
+	Code     string
 	Datetime time.Time
 }
 




diff --git a/db/db.go b/db/db.go
index bc112ed62e6cc8fe96acf68117bc3f1e890ba681..1be25d48da353068c41d0ce5e3f1aca5ba5a280b 100644
--- a/db/db.go
+++ b/db/db.go
@@ -615,7 +615,7 @@ 	if filter != "" {
 		whereClause = "and c1.title like '%" + filter + "%'"
 	}
 
-	rows, err := db.Query(`select item_id, item_type, cover, status, title, year_start, based_on, genres, runtime, part, time from experiences natural join item_cache where username = ? `+whereClause+` order by time desc limit ?,18;`, username, offset)
+	rows, err := db.Query(`select case when substr(e.item_id, 1, pos-1) = '' then e.item_id else substr(e.item_id, 1, pos-1) end as id, substr(e.item_id, pos+1) as code, e.item_type, time, title, year_start, collection, part from (select *, instr(item_id, '/') as pos from experiences) e join item_cache c on id = c.item_id and e.item_type = c.item_type where username = ? `+whereClause+` order by time desc limit ?,18;`, username, offset)
 
 	if err != nil {
 		fmt.Fprintf(os.Stderr, "Select err: %v\n", err)
@@ -625,9 +625,10 @@ 	defer rows.Close()
 
 	for rows.Next() {
 		var (
-			entry    datastructure.ExperiencesEntry
+			entry datastructure.ExperiencesEntry
 		)
-		err := rows.Scan(&entry.Id, &entry.Type, &entry.Cover, &entry.Status, &entry.Title, &entry.YearStart, &entry.BasedOn, &entry.Genres, &entry.Runtime, &entry.Part, &entry.Datetime)
+		err := rows.Scan(&entry.Id, &entry.Code, &entry.Type, &entry.Datetime, &entry.Title, &entry.YearStart, &entry.Collection, &entry.Part)
+		entry.Part += 1
 		if err != nil {
 			fmt.Println("Scan error")
 			return datastructure.Experiences{}, err




diff --git a/templates/experiences.html b/templates/experiences.html
index 8b34d1b9650afd79c4a691cca7e0fe7a839f7476..d3ea2366a76778ab610ad5f1a708307db59779ac 100644
--- a/templates/experiences.html
+++ b/templates/experiences.html
@@ -59,14 +59,12 @@ 				{{- range .Data.List -}}
 					{{- if ne $lastDate ($.FormatDate .Datetime)}}
 				<div class="w12 margin-lr-5">
 					<span class="sans">{{$.FormatDateNice .Datetime $.State.User.Timezone}}</span><hr class="margin-top-_25 margin-bottom-1"/>
-					{{- end -}}
+					{{- end}}
 					<p>
-					<span class="sans">{{.FormatDatetime $.Strings}}</span>
-					<a href="/{{.Type}}s/{{.Id}}" class="sans decoration-none">{{.Title}} ({{.YearStart}})</a>
-					<!-- if series then with item_id=id/code show code -->
-						{{- if gt .Collection 0 -}}
-					({{.Collection}} <!-- collection name and link --> #{{.Part}})
-						{{- end -}}
+						<span class="sans">{{.FormatDatetime $.Strings}}</span>
+						<a href="/{{.Type}}s/{{.Id}}" class="sans decoration-none">{{.Title}} ({{.YearStart}})</a>
+						{{if eq .Type "tvserie"}}<span class="sans">{{.Code}}</span>{{end}}
+						{{- if gt .Collection 0 -}}<span class="sans">({{.Collection}} <!-- collection name and link --> #{{.Part}})</span>{{- end}}
 					</p>
 					{{- if and (ne $lastDate ($.FormatDate .Datetime)) (ne $lastDate "")}}
 				</div>