Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 09-18-2016, 08:12 AM   #1
Tanjamuse
Guru
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 705
Karma: 5258
Join Date: Jan 2014
Device: Samsung Galaxy Tab 3
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?
Attached Thumbnails
Click image for larger version

Name:	table.jpg
Views:	37
Size:	27.1 KB
ID:	151722  
Tanjamuse is offline   Reply With Quote
Old 09-18-2016, 03:17 PM   #2
Terisa de morgan
Wizard
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 3,468
Karma: 3212558
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Aura, Kobo Mini, Kobo Aura HD, elephone, iPad, Galaxy Tab3 8
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
But I'm not so sure that a rating column could be a composite column.

Last edited by Terisa de morgan; 09-18-2016 at 03:20 PM.
Terisa de morgan is offline   Reply With Quote
Old 09-18-2016, 03:32 PM   #3
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 7,803
Karma: 2046464
Join Date: Jan 2010
Location: France
Device: Many android devices
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:
  • Using composite columns to display ratings is hard. It is especially hard to display 1/2 star ratings. CC will never display them as anything except numbers.
  • If you use a visual rating column (custom or otherwise) then the rating must be recomputed during each calibre session where the read_count could change.
A plugin could look at the values in read_count and set a custom rating column to the "right" value.

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.
chaley is offline   Reply With Quote
Old 09-18-2016, 03:43 PM   #4
Terisa de morgan
Wizard
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 3,468
Karma: 3212558
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Aura, Kobo Mini, Kobo Aura HD, elephone, iPad, Galaxy Tab3 8
I agree with chaley that this should be a plugin (it is the only way to show ratings). You would need to configure:
  • column for read_count
  • column for rating

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).
Terisa de morgan is offline   Reply With Quote
Old 09-18-2016, 03:50 PM   #5
Terisa de morgan
Wizard
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 3,468
Karma: 3212558
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Aura, Kobo Mini, Kobo Aura HD, elephone, iPad, Galaxy Tab3 8
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.
Terisa de morgan is offline   Reply With Quote
Old 09-19-2016, 01:37 AM   #6
Tanjamuse
Guru
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 705
Karma: 5258
Join Date: Jan 2014
Device: Samsung Galaxy Tab 3
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:
Originally Posted by Terisa de morgan View Post
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
But I'm not so sure that a rating column could be a composite column.
Q: Can a template for a custom composite column set the value of a custom Ratings column?

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: http://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:
Originally Posted by chaley View Post
It is especially hard to display 1/2 star ratings. CC will never display them as anything except numbers.
Will CC display the half stars for a custom Ratings column ?

Quote:
Originally Posted by chaley View Post
A plugin could look at the values in read_count and set a custom rating column to the "right" value.
Why in a plug-in and not in the read_count composite column template which already exists and already works ?

Quote:
Originally Posted by Terisa de morgan View Post
... You would need to configure:
  • column for read_count
  • column for rating
I already have the columns, see attachment

Quote:
Originally Posted by Terisa de morgan View Post
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.
Rating columns (built in and custom) can't be accessed in Bulk Metadata Search and Replace

Quote:
Originally Posted by Terisa de morgan View Post
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.
Column icons don't show in CC - that's why I want to use a custom Ratings column

Tanjamuse
Attached Thumbnails
Click image for larger version

Name:	Capture.jpg
Views:	12
Size:	29.4 KB
ID:	151740  
Tanjamuse is offline   Reply With Quote
Old 09-19-2016, 03:24 AM   #7
Terisa de morgan
Wizard
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 3,468
Karma: 3212558
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Aura, Kobo Mini, Kobo Aura HD, elephone, iPad, Galaxy Tab3 8
Well, reading your message we have:
  • You want to show half star in CC => You need the new custom rating colum
  • A custom rating column is a simple type => It cannot be a composite column => No chance of template coming from other fields

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
Terisa de morgan is offline   Reply With Quote
Old 09-19-2016, 05:27 AM   #8
Tanjamuse
Guru
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 705
Karma: 5258
Join Date: Jan 2014
Device: Samsung Galaxy Tab 3
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.
Tanjamuse is offline   Reply With Quote
Old 09-19-2016, 05:37 AM   #9
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 7,803
Karma: 2046464
Join Date: Jan 2010
Location: France
Device: Many android devices
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):
  • Edit metadata/single
  • Edit metadata/bulk
  • Search & Replace
  • Manual editing on the spreadsheet
  • A plugin that does the operation you want
  • Calibre's command line functions
  • A standalone python program that uses calibre's database API.
Of course, it is possible to write a program that directly manipulates metadata.db without using calibre functions. I strongly suggest that you don't go there because the likelihood of getting something wrong is very high.

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.
chaley is offline   Reply With Quote
Old 09-19-2016, 05:46 AM   #10
Terisa de morgan
Wizard
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 3,468
Karma: 3212558
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Aura, Kobo Mini, Kobo Aura HD, elephone, iPad, Galaxy Tab3 8
Quote:
Originally Posted by Tanjamuse View Post
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 ]?
Short answer: No


Quote:
Originally Posted by Tanjamuse View Post
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.
I don't understand your comment. Are you requesting something like this? (S) #read_count:<= 4 and #read_count:> 2 and #my_rating:=2 =>(BE) #my_rating = 3.

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.
Terisa de morgan is offline   Reply With Quote
Old 09-19-2016, 07:12 AM   #11
Tanjamuse
Guru
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 705
Karma: 5258
Join Date: Jan 2014
Device: Samsung Galaxy Tab 3
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.
Tanjamuse is offline   Reply With Quote
Old 09-19-2016, 08:26 AM   #12
Terisa de morgan
Wizard
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 3,468
Karma: 3212558
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Aura, Kobo Mini, Kobo Aura HD, elephone, iPad, Galaxy Tab3 8
Quote:
Originally Posted by Tanjamuse View Post
Don't worry Chaley I'm not going to tinker with the database
You wouldn't be the first Prior to kovid's suggestion, I was using old sql sentences to copy ratings + half_star to my_ratings
Terisa de morgan is offline   Reply With Quote
Old 09-19-2016, 09:34 AM   #13
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 7,803
Karma: 2046464
Join Date: Jan 2010
Location: France
Device: Many android devices
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".
chaley is offline   Reply With Quote
Old 09-19-2016, 10:04 AM   #14
Terisa de morgan
Wizard
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 3,468
Karma: 3212558
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Aura, Kobo Mini, Kobo Aura HD, elephone, iPad, Galaxy Tab3 8
Thank you, chaley!
Terisa de morgan is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 01:53 AM.


MobileRead.com is a privately owned, operated and funded community.