Giter Site home page Giter Site logo

Comments (4)

alexdanilowicz avatar alexdanilowicz commented on June 12, 2024

Instead of having the user export a .vcf, we are likely going to go with reading their populated *.abcddb file instead.

from leftonread.

alexdanilowicz avatar alexdanilowicz commented on June 12, 2024

Going to work on this next, starting tomorrow.

from leftonread.

alexdanilowicz avatar alexdanilowicz commented on June 12, 2024

Posting this here because I have nowhere else to put it.

Implementation flow:

  • 1) copy the AddressBook.db file to the .leftonread folder
  • 2) loop over all possible the AddressBook.db files and find the one that is populated
  • 3) if none are populated, you don't have to skip (6) because of the coalesce usage in 8... so just continue onward
  1. with the populated one, open it, and ATTACH it to the existing chat.db database connection
  • If successfully attached, you should be able to do the following:

  • -- UPDATE 4.5) Create the contacts table. See query below.

-- 5) NOTE: add this to a try/catch. If it fails, then that means the column exists so just skip to 6
ALTER TABLE handle ADD contact_name VARCHAR(255);

-- 6)
UPDATE handle 
SET contact_name = (SELECT contacts_table.contact_name FROM contacts_table WHERE handle.id = contacts_table.contact_phone);

-- 7) Close the addressbook DB connection now

-- 8)
-- downstream usage in core table
SELECT coalesce(contact_name, handle.id) as contact FROM handle

The whole idea is to alter the existing chat.db handle table directly by adding a contact_name column to it directly.

PROS:

  • We worry about this one on initializing and then never again
  • We don't have to worry about JOINs down the road
  • We simply reference the handle table every time and use a coalesce. You could probs get around the coalesce if I gave this more thought.
  • We can close the addressbook.db file immediately

CONS:

  • contacts isn't its own table... which would make more sense logically?

from leftonread.

alexdanilowicz avatar alexdanilowicz commented on June 12, 2024

This coming along nicely. For posterity's sake, the query for this will be:

CREATE TABLE CONTACTS_TABLE AS
WITH CONTACTS_CLEAN_TABLE AS (
SELECT 
	ZABCDRECORD.Z_PK, 
	ZABCDRECORD.ZFIRSTNAME,
	ZABCDRECORD.ZLASTNAME, 
	-- TODO: I understand this is ugly... use regex.
	replace(replace(replace(replace(replace(replace(ZABCDPHONENUMBER.ZFULLNUMBER, "(", ""), ")", ""), "_", ""), "-", ""), " ", ""), "+", "") as ZFULLNUMBER
FROM ZABCDRECORD
LEFT JOIN ZABCDPHONENUMBER ON ZABCDPHONENUMBER.ZOWNER = ZABCDRECORD.Z_PK
WHERE ZABCDPHONENUMBER.ZFULLNUMBER IS NOT NULL
)
--- NOTE: in the chat.db the format is +1619... in other words
--- chat.db lists the country code always. The addressbook.db, however, does not always include the country code.
--- Therefore, we remove the + and the country code, and FILTER on the 10-digit length.
--- All phone numbers in the US/Canada are 10-digit... this assumption may not work as well for users in other countries
SELECT 
ZFIRSTNAME || " " || ZLASTNAME  as contact_name,
CASE WHEN LENGTH(ZFULLNUMBER) > 10
	THEN SUBSTR(ZFULLNUMBER, -10, 10)
	ELSE ZFULLNUMBER
END AS contact_phone
FROM CONTACTS_CLEAN_TABLE

from leftonread.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.