![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
Help with ratings column
I have a composite custom column #read_count, its template is {#date_read_history:count(,)}
I want to have a custom rating column (#my_rating) that is recalculated whenever #read_count changes. My understanding is that the underlying value of a rating is an integer between 1 and 10. The attached table shows how I'd like the #read_count column to be used to define a value for #my_rating. I assume I need to extend the #read_count's existing template to compute the value of #my_rating - but I have no idea how to code that. Could someone help me with it please? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
For me, this is not a template but a program (I feel more comfortable with it):
Code:
if (read_count < 10): rating = (read_count - 1) / 2 + 1 else: rating = 10 Last edited by Terisa de morgan; 09-18-2016 at 03:20 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,311
Karma: 7957679
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
If you really want to do this in the way you describe then you need yet another plugin like the one being discussed for read_count. There are two reasons:
I am not interested in writing such a plugin. It has zero value for me, but I would be required to spend time to maintain it. At this point in my life I am busy shedding responsibilities, not adding new ones. |
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
I agree with chaley that this should be a plugin (it is the only way to show ratings). You would need to configure:
And the plugin would apply to some books, calculating the rating. The first "fulfill" of columns could be done with search and bulk metadata edit. For example: read_count:<=2 and rating:false => Assign 1 to rating... And so on. But, later, for maintaining it, you should execute the plugin any time that read_count changes (I do something similar for books in a series, and it's a manual task). |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Rereading chaley's message I've been aware that I'm too "up-to-date". I still have a column which makes something similar (composite and stars....), that I've been using for showing half stars.
You can define the function for "my_ratings" and, instead of using the standard rating columns with stars that calibre shows", you can define icons for the column associated to its value, so you can get the same effect. Yes, it will be recomputed... as any custom column... but it can be done. Last edited by Terisa de morgan; 09-18-2016 at 03:56 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 | ||||||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
Thanks for the replies
There seems to be a misunderstanding, I wasn't suggesting the #my_ratings column be a composite column, that's why I wrote:- "...have a custom rating column (#my_rating)..." I then went on to write:- "I need to extend the [ composite column ] #read_count's existing template [ {#date_read_history:count(,)} ] to compute the value of [ the rating column ] #my_rating." Should have written, "I think I need to extend" ![]() Regarding plugins:- I don't really want to have my own plugins, firstly I have no programming skills, nor much of an inclination to acquire them, and secondly I would have to maintain them when a change to calibre or something (Qt, Windows etc) causes problems. Here's my detailed reply: Quote:
If the answer to that is Yes then: Could the template of the composite column #read_count be recoded into Program Mode, and could the logic of your code fragment be included it, and if so how ? Maybe it needs a python function - example only: https://www.mobileread.com/forums/sho...02&postcount=1 ![]() Baby steps please ![]() If the answer is No, then I need to consider the options - like do nothing. ================================== Quote:
Quote:
![]() Quote:
Quote:
![]() Quote:
![]() Tanjamuse |
||||||
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Well, reading your message we have:
Taking into account these two facts, I think the only solution is a plugin, where you can manipulate directly the database to assign the value you need to a simple column or search and bulk edit. BTW: When I was talking about bulk edit, I wasn't thinking about S&R but directly edit. Let's say: * #read_count:<=2 and #my_rating: False => A set of registers => Bulk edit of those records => my_rating: 1 See this thread. Last edited by Terisa de morgan; 09-19-2016 at 03:30 AM. Reason: Added link |
![]() |
![]() |
![]() |
#8 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
Terisa – thanks
Could you (or someone) answer my first question - as Yes or No? Q: Can a template for a custom composite column [ #read_count ] set the value of a custom Ratings column [ #my_rating ]? As I already said if its ‘No’, I want to consider my options, which include:- a PI; do nothing; replace my Android tablet with a Windows tablet and run full-blown calibre on it; or wait to see what opportunities the new calibre server might bring. BTW doing it manually in Bulk Custom Edit might be OK if I there was a way increase the rating by half a star on selected books, so a 1 star books would get bumped to 1.5 stars and 2.5 star would get bumped to 3 stars etc. But I don’t think that’s possible. |
![]() |
![]() |
![]() |
#9 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,311
Karma: 7957679
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
To reinforce what Terisa de morgan said:
1) A template computes a value that is used in the template's context, such as in a composite column. A template by itself cannot set the value of a column. It might be possible to force a custom template function to write something into the database but that would break all sorts of rules and would likely have unpleasant side effects. 2) You set the value of a column using a calibre function. The choices are (approximately):
My feeling is that a plugin or standalone program would be easier to write and maintain than the complex S&R expressions and templates that you are currently building. But as you say, doing so requires knowledge you don't currently have. Evaluating the trade off is up to you. |
![]() |
![]() |
![]() |
#10 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Quote:
Quote:
You have to do it periodically... If you are talking about #my_rating = #my_rating + 1, I'm not aware of a way to do it from the GUI interface. Last edited by Terisa de morgan; 09-19-2016 at 05:50 AM. |
||
![]() |
![]() |
![]() |
#11 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
Thanks to both Chaley and Terisa. I'm going to ponder your suggestions.
Don't worry Chaley I'm not going to tinker with the database and I'm down to one S&R which appends the date_read to date_read_history (a tag like column), plus a composite column that counts the date_read_history. Thanks once again to both of you. |
![]() |
![]() |
![]() |
#12 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
|
![]() |
![]() |
![]() |
#13 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,311
Karma: 7957679
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
FWIW: I just submitted changes to add rating-type columns to bulk search & replace.
The replacement value must be empty or an integer between 0 and 10. The value is two times the number of stars. For the standard rating column the number is adjusted down to be 0, 2, 4, 6, 8, or 10 because half-stars aren't supported there. The value 0 becomes "unrated". |
![]() |
![]() |
![]() |
#14 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,581
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Thank you, chaley!
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom Column for Half-Star Ratings | Loosheesh | Calibre | 2 | 09-14-2016 01:45 PM |
My Ratings column | MerlinMama | Calibre | 5 | 09-08-2016 07:20 AM |
grouping does not work for custom column type ratings | comox | Calibre Companion | 2 | 09-24-2014 01:54 PM |
Download number of ratings and exact ratings from amazon (partly solved) | Bücherwurm1 | Library Management | 0 | 08-01-2014 04:23 AM |
Rename the Ratings column? | mlevin77 | Library Management | 5 | 04-13-2012 09:36 PM |