Harvest email addresses from messages.
Go tool for reading original messages from DB and filling out contact table.
SQL scripts for building address book table from most commonly referenced
names per unique email address.
This commit is contained in:
31
pg/fill-abook.sql
Normal file
31
pg/fill-abook.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
DROP TABLE abook;
|
||||
|
||||
CREATE TABLE
|
||||
abook (count, name, address)
|
||||
AS SELECT
|
||||
DISTINCT ON(lower(address))
|
||||
named.count,
|
||||
named.name || lower(unnamed.address),
|
||||
lower(unnamed.address)
|
||||
FROM
|
||||
contact unnamed
|
||||
LEFT OUTER JOIN (
|
||||
SELECT
|
||||
DISTINCT ON (lower(address))
|
||||
count(name),
|
||||
name,
|
||||
lower(address) AS laddr
|
||||
FROM
|
||||
contact
|
||||
WHERE
|
||||
name != ''
|
||||
GROUP BY
|
||||
lower(address), name
|
||||
ORDER BY
|
||||
lower(address),
|
||||
count DESC,
|
||||
name
|
||||
) named
|
||||
ON
|
||||
named.laddr = lower(unnamed.address)
|
||||
;
|
||||
7
pg/init-contact.sql
Normal file
7
pg/init-contact.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
DROP TABLE contact;
|
||||
|
||||
CREATE TABLE contact (
|
||||
hash CHAR(40) REFERENCES original (hash),
|
||||
name TEXT,
|
||||
address TEXT
|
||||
);
|
||||
Reference in New Issue
Block a user