<div dir="ltr">I do believe use of DBIx::Class in existing subs is both good and encouraged! That is, as long as there are no regressions! It seems like a good idea to add that field to the borrowers table. I'm sure there are many Koha administrators that need to sync data between Koha and other systems, and it seems like this field could be useful in a more general fashion.<div>
<br></div><div>Kyle</div></div><div class="gmail_extra"><br clear="all"><div><a href="http://www.kylehall.info" target="_blank">http://www.kylehall.info</a><br>ByWater Solutions ( <a href="http://bywatersolutions.com" target="_blank">http://bywatersolutions.com</a> )<br>
Meadville Public Library ( <a href="http://www.meadvillelibrary.org" target="_blank">http://www.meadvillelibrary.org</a> )<br>Crawford County Federated Library System ( <a href="http://www.ccfls.org" target="_blank">http://www.ccfls.org</a> )<br>
Mill Run Technology Solutions ( <a href="http://millruntech.com" target="_blank">http://millruntech.com</a> )<br></div>
<br><br><div class="gmail_quote">On Tue, Jan 21, 2014 at 5:17 AM, Magnus Enger <span dir="ltr"><<a href="mailto:magnus@enger.priv.no" target="_blank">magnus@enger.priv.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi!<br>
<br>
I am working on Bug 11401 - Add support for Norwegian national library card:<br>
<a href="http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11401" target="_blank">http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11401</a><br>
<br>
The goal is to sync patrons in Koha back and forth to the Norwegian<br>
national patron database. In order to do this I need to keep track of<br>
- which patrons should be synced (they can choose to opt out of the syncing)<br>
- a sync status, to see which patrons are new, which have been changed<br>
and which are already synced<br>
- the date of the last sync<br>
<br>
I am a bit undecided about whether I should use extended patron<br>
attributes for this, or add columns to the "borrowers" table. Some<br>
pros and cons:<br>
- Attributes are less intrusive, they only need to be added to systems<br>
that want to sync with the Norwegian national patron database.<br>
- New columns could be re-used by others, to implement other syncing<br>
schemes, and they are easier to work with, as far as I can see.<br>
I am currently leaning towards adding columns.<br>
<br>
Now the thing is that I want to change the "syncstatus" every time<br>
AddMember or ModMember is called, so I want to add some logic to these<br>
subroutines, perhaps like this ("..." indicates lines that have been<br>
edited out for clarity):<br>
<br>
use Koha::Database;<br>
...<br>
sub AddMember {<br>
    my (%data) = @_;<br>
    ...<br>
    $data{'borrowernumber'}=InsertInTable("borrowers",\%data);<br>
<br>
    # If NorwegianPatronDBEnable is enabled, we set the nllastsync<br>
attribute to something that a<br>
    # cronjob will use for syncing with NL<br>
    if ( C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {<br>
        my $borrower =<br>
Koha::Database->new->schema->resultset('Borrower')->find(<br>
$data{'borrowernumber'} );<br>
        $borrower->update( { 'syncstatus' => 'new' } );<br>
    }<br>
    ...<br>
}<br>
<br>
Would that be an OK way to do it? Or is mixing in DBIC in existing<br>
subroutines like this frowned upon?<br>
<br>
Would it be cleaner to add a module like Koha::Borrower::Sync (that<br>
could be re-used by other syncing schemes), with methods like<br>
SetBorrowerSyncstatus( $patronnumber, $value ) that would then look<br>
something like this:<br>
<br>
use Koha::Database;<br>
sub SetBorrowerSyncstatus {<br>
    my ( $borrowernumber, $value ) = @_;<br>
    my $borrower =<br>
Koha::Database->new->schema->resultset('Borrower')->find(<br>
$borrowernumber );<br>
    $borrower->update( { 'syncstatus' => 'new' } );<br>
}<br>
<br>
Any advice on this would be much appreciated!<br>
<br>
Best regards,<br>
Magnus<br>
_______________________________________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org">Koha-devel@lists.koha-community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" target="_blank">http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
website : <a href="http://www.koha-community.org/" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" target="_blank">http://bugs.koha-community.org/</a><br>
</blockquote></div><br></div>