Hi,
On Mon, Mar 30, 2015 at 5:21 PM, Andreas Tille <[email protected]> wrote:
> Hi Akshita,
>
> Similarly you should have a close look at the bibref importer. Hmmm,
> now when I'm writing this I remember there is an actual flar in the
> bibref importer. Originally the references were imported from the data
> gathered by Umegaya[3] but besides the fact that it is currently broken
> this only gathers data of *existing* Debian packages. However, the
> Blends web sentinel also wants data from packages which are not yet on
> the Debian mirror but only in VCS. So the blends_prospective_gatherer
> *also* injects references in the bibref table. Currently it does this
> only if an entry for the package in question is lacking and does not
> override the bibref gatherer. However, since Charles Plessy
> confirmed[4] that there is a problem we probably should force the
> reference from machine-readable data in any case. Hmmm, I hope, this
> was not too confusing. (Otherwise, I will hopefully find some time to
> fix this quickly.)
>
>
It took me some time but if I understand correctly
'blends_prospective_gatherer' inserts new references in the bibref table
(irrespective of whether the references are from VCS or Debian Mirror) but
does not update the already existing references (if references are
different in Debian Mirror and VCS. The references inserted from Debian
Mirror remain unchanged).
If this is the issue, then this can be solved by using "REPLACE" instead of
plain "INSERT".
In blends_prospective_gatherer, the query responsible for inserting
references in bibref table is:
# Inserting references should be save because above we are testing for
existant table entries
query = """PREPARE bibref_insert (text, text, text, text, int) AS
INSERT INTO bibref
(source, key, value, package, rank)
VALUES ($1, $2, $3, $4, $5)"""
cur.execute(query)
bibquery = "EXECUTE bibref_insert (%(source)s, %(key)s, %(value)s,
%(package)s, %(rank)s)"
This "query" can be changed to :
query = """PREPARE bibref_insert (text, text, text, text, int) AS REPLACE
INTO bibref
(source, key, value, package, rank)
VALUES ($1, $2, $3, $4, $5)"""
'bibref' table has "source", "key", "package", "rank" as its PRIMARY KEYS.
If the record is not already present it is inserted, else the record is
updated.
Another method could be to "INSERT", then check the number of rows
affected. If number of rows affected are 0, then we could UPDATE".
Am I on the right track ? Also, how do I test the changes that I make ?
--
Regards,
Akshita Jha