Skip to content

Commit

Permalink
Merge pull request #156 from Whats-Cookin/claim-graph-view
Browse files Browse the repository at this point in the history
add a claimGraph route and use that for the graph explorer
  • Loading branch information
gvelez17 authored Nov 25, 2024
2 parents b4b0092 + fdca539 commit c961ade
Show file tree
Hide file tree
Showing 18 changed files with 433 additions and 6,888 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/node_modules
yarn.lock
build
*.env*
dev.db
model.json
.vscode
.DS_Store
*.env.test*
*.env.test*
93 changes: 93 additions & 0 deletions prisma/migrations/20230713083940_postgres_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
-- CreateEnum
CREATE TYPE "AuthType" AS ENUM ('PASSWORD', 'GITHUB');

-- CreateEnum
CREATE TYPE "EntityType" AS ENUM ('PERSON', 'ORGANIZATION', 'CLAIM', 'IMPACT', 'EVENT', 'DOCUMENT', 'PRODUCT', 'PLACE', 'UNKNOWN', 'OTHER');

-- CreateEnum
CREATE TYPE "IssuerIdType" AS ENUM ('DID', 'ETH', 'PUBKEY', 'URL');

-- CreateEnum
CREATE TYPE "HowKnown" AS ENUM ('FIRST_HAND', 'SECOND_HAND', 'WEB_DOCUMENT', 'VERIFIED_LOGIN', 'BLOCKCHAIN', 'SIGNED_DOCUMENT', 'PHYSICAL_DOCUMENT', 'INTEGRATION', 'RESEARCH', 'OPINION', 'OTHER');

-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"email" TEXT,
"passwordHash" TEXT,
"name" TEXT,
"authType" "AuthType" NOT NULL DEFAULT 'PASSWORD',
"authProviderId" TEXT,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Node" (
"id" SERIAL NOT NULL,
"nodeUri" TEXT NOT NULL,
"name" TEXT NOT NULL,
"entType" "EntityType" NOT NULL,
"descrip" TEXT NOT NULL,
"image" TEXT,
"thumbnail" TEXT,

CONSTRAINT "Node_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Edge" (
"id" SERIAL NOT NULL,
"startNodeId" INTEGER NOT NULL,
"endNodeId" INTEGER,
"label" TEXT NOT NULL,
"thumbnail" TEXT,
"claimId" INTEGER NOT NULL,

CONSTRAINT "Edge_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Claim" (
"id" SERIAL NOT NULL,
"subject" TEXT NOT NULL,
"claim" TEXT NOT NULL,
"object" TEXT,
"statement" TEXT,
"effectiveDate" TIMESTAMP(3),
"sourceURI" TEXT,
"howKnown" "HowKnown",
"dateObserved" TIMESTAMP(3),
"digestMultibase" TEXT,
"author" TEXT,
"curator" TEXT,
"aspect" TEXT,
"score" DOUBLE PRECISION,
"stars" INTEGER,
"amt" DOUBLE PRECISION,
"unit" TEXT,
"howMeasured" TEXT,
"intendedAudience" TEXT,
"respondAt" TEXT,
"confidence" DOUBLE PRECISION,
"issuerId" TEXT,
"issuerIdType" "IssuerIdType",
"claimAddress" TEXT,
"proof" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"lastUpdatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "Claim_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- AddForeignKey
ALTER TABLE "Edge" ADD CONSTRAINT "Edge_startNodeId_fkey" FOREIGN KEY ("startNodeId") REFERENCES "Node"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Edge" ADD CONSTRAINT "Edge_endNodeId_fkey" FOREIGN KEY ("endNodeId") REFERENCES "Node"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Edge" ADD CONSTRAINT "Edge_claimId_fkey" FOREIGN KEY ("claimId") REFERENCES "Claim"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
7 changes: 5 additions & 2 deletions scripts/README_FIXTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ python convert_to_inserts.py # creates fixture_data.sql

## Load the fixture data into local db

On your local development machine:
If using postgres in a docker container,

```
psql claim -f insert_fixture.sql
docker cp fixture_data postgres:/
docker exec postgres psql -U postgres -d claim -f /fixture_data/import_fixture.sql
```
34 changes: 34 additions & 0 deletions scripts/clean_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
def clean_file(input_file, output_file):
with open(input_file, 'r') as f:
lines = f.readlines()

cleaned_records = []
current_record = None

for line in lines:
line = line.strip()
if not line:
continue

# If line starts with a number, it's a new record
if line[0].isdigit():
if current_record:
cleaned_records.append(current_record)
current_record = line
else:
# It's a continuation of previous description
if current_record:
current_record = current_record.rstrip() + " " + line

# Don't forget the last record
if current_record:
cleaned_records.append(current_record)

with open(output_file, 'w') as f:
for record in cleaned_records:
f.write(record + '\n')

# Clean each file
clean_file('./fixture_data/nodes.txt', './fixture_data/nodes_clean.txt')
clean_file('./fixture_data/edges.txt', './fixture_data/edges_clean.txt')
clean_file('./fixture_data/claims.txt', './fixture_data/claims_clean.txt')
7 changes: 0 additions & 7 deletions scripts/fixture_data/claims.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,11 @@ https://www.linkedin.com/feed/update/urn:li:activity:7192648658339647488/
33923|https://voiceofachild.org|rated||we have English and computer training
33929|https://live.linkedtrust.us/claims/33830|rated||It was really good trainings .
118499|https://www.amurt.net|impact||In Ebonyi, Nigeria, Amurt ( which is the organization that works in providing help to people) work to provide good health to people of Ebonyi state.
The work with hospitals within the state to achieve this. They have been doing since 2010.
The help to provide solid health care to baby and mother that have complication in child delivery. They foot the bills and make sure that both the mother and child are healthy as they stay in the hospital.
They also cater for care that are extreme and need treatment asap by using their ambulance for quick response. They can also pay for the bills for this too.
Sometime they visit hospital to fund people that can pay for their bills so that can be discharged. They have representative of themselves in several hospital and they are across the state of Ebonyi.
In summary, they exist to make sure people have a sound health care with small or no cost.
33594|https://VoiceOfAChild.org|impact||Voice of a Child donated $6500 to create a computer learning center in Jarablus, Syria starting with 36 students.
These young men and women are learning job skills and have Internet access in a secure location.
33075|https://lifesapitch.io/|rated||And, Ro has continued to be an incredibly valuable collaborator to our team, offering quick insights and help and genuinely sensitive to our needs and position.
33920|https://voiceofachild.org|rated||thank your for your help VOC
118505|https://live.linkedtrust.us/claims/118502|rated||I spoke with Alice and she indicated that she was given a sum of 30 thousand naira to start a groundnut business in 2016, and she is still in the business.
118549|https://live.linkedtrust.us/claims/118541|rated||
33931|https://live.linkedtrust.us/claims/33830|rated||it was great trainings , thank you very much VOC .
118542|https://live.linkedtrust.us/claims/118541|rated||
33922|https://live.linkedtrust.us/claims/33830|agree||
(38 rows)
38 changes: 38 additions & 0 deletions scripts/fixture_data/claims_clean.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
118501|https://live.linkedtrust.us/claims/118499|rated||On the 3rd of May, 2024, I visit AMURT in Ebonyi, Nigeria. I was blown away with what they are doing and have done there. They have succeeded in converting some local health center to a standard ones. I visited some of their health centers and spoke with some beneficiaries, not only the beneficiaries but also the communities was happy with the project so far. Their impact on the people of Ebonyi have been great.
118506|https://live.linkedtrust.us/claims/118502|rated||I went with kene to ebonyi, to visit most of amurts health centres, and i love the work the team is doing
118548|https://live.linkedtrust.us/claims/118499|rated||
118540|https://live.linkedtrust.us/claims/118537|rated||I dunno about so professional but I am Golda and i can attest i am the co-founder of WhatsCookin.us and LinkedTrust!
118541|https://www.amurt.net|rated||I know several of the people involved with AMURT and trust that they are genuine and ethical people, because I have also seen the impact of their other projects with people I know. In particular I have very high confidence in Kirit Dave as I am familiar with a kindergarten he started in Jarablus
118500|https://live.linkedtrust.us/claims/118499|rated||On the 3rd of March 2024, I visited AMURT in Ebonyi, Nigeria to check out the facilities and work they do. I was blowed away by their achievement due the way they converted health centers to a mini hospital. I spoke with some beneficiary of this project and not only them but the community has been glad since the beginning of the project. I visited some health center and check them out.
9927|https://live.linkedtrust.us/claims/9924|verified||I have spoken to Mohammed who gave these funds directly to the recipient on the ground in Jarablus
118509|https://live.linkedtrust.us/claims/118502|rated||This is Dada. I received Kene and Peter at the motor park in Ebonyi and took them to AMURT office to introduce them to some of AMURT key staff. Kene and Peter visited Odeligbo Health Center in Ikwo LGA and Ephuenyim Health Center in Abakaliki LGA accompanied by Medical Director Dr. Opoke and COO Ogbonna Agha. They met staff, patients and their families and some community members. The model for the Economic Empowerment Scheme is described as a Cooperatively managed revolving credit scheme.
33921|https://voiceofachild.org|rated||سعيد جدا بالتدريبات
9926|https://linkedtrust.us/claims/992|verified||I have spoken to Mohammed who gave these funds directly to the recipient on the ground in Jarablus
33932|https://live.linkedtrust.us/claims/33830|rated||لقد تابعت التدريبات وكانت مميزة جدا شكرا جزيلا لكم .
33835|https://www.linkedin.com/in/agnes-koinange|rated||Agnes Koinage is a skilled, grounded and reliable software developer with Typescript and web3 skills.https://www.linkedin.com/in/goldavelez/
33919|https://live.linkedtrust.us/claims/33830|agree||it was amazing trainings
118508|https://www.linkedin.com/in/ahlam-sayed-a54155289/|rated||Molly was able to do design on a hard problem we had that had confused others, appreciate her work on the design of this app to improve the feed - check back to see the results soon
33818|https://techsoup.org|impact||Billy Bicket at TechSoup gave some really great advice and strategy during a 1 hr, extremely valuable.
33096|https://www.linkedin.com/in/goldavelez/|same_as|https://noo.network/user/455d0177-280b-4659-a287-8a36cdb0f7d4|this is me! in both places
118550|https://voiceofachild.org|impact|https://www.amurt.net|Voice of a Child is one of the largest cash contributors to the AMURT Nigeria projects since its inception. Through our fundraising and cash contributions, they have impacted over $50,000 in cash. Additionally, they have contributed significantly towards medical ultrasound machines and ambulances.
33305|https://noo.network/api/murmur/network/455d0177-280b-4659-a287-8a36cdb0f7d4|same_as|https://noo.network/user/455d0177-280b-4659-a287-8a36cdb0f7d4|One is the user friendly NooNet and the other is the api, they are both same data - me!
118546|https://live.linkedtrust.us/claims/118499|rated||My name is Ani Peter Benjamin, and I am a software engineer with the LinkedTrust team. In early May 2024, I traveled to Ebonyi State with Orjiene Kenechukwu to observe the remarkable work being done by AMURT in the community. As a Nigerian, I am delighted to see the significant improvements in underdeveloped communities. AMURTs strategies to combat poverty in rural areas, such as providing innovative cooperative ideas, have greatly assisted local women in taking better care of their families. Additionally, AMURT has established awareness groups to educate women on proper childbearing practices and to engage the youth in educational initiatives. The impact of AMURTs efforts on Ebonyi State has been profoundly positive, especially in their health centers. I am personally impressed and supportive of the progress they have made.
118502|https://www.amurt.net/safeguarding-the-lives-of-women-and-children/|impact|| Peter and I visited AMURT in Ebonyi, Nigeria, representing Voice of a Child via LinkedTrust. We were warmly welcomed by Dada. During our visit, we met with key individuals including Dada, Peter, the COO, and heads of various departments. We learned about their collaboration with the Government and Community to provide high-quality healthcare services, especially focusing on maternal and child health. Our visit to health centers showcased their dedication. We spoke with beneficiaries and learned about the impact of AMURTs initiatives, including economic empowerment through cooperative management schemes and increased healthcare utilization rates through outreach efforts. AMURTs holistic approach includes surgical interventions for children. Our visit left us inspired by their commitment to transforming lives, and we anticipate continued collaboration in advancing healthcare and socioeconomic development in Ebonyi and beyond. https://www.linkedin.com/feed/update/urn:li:activity:7192648658339647488/
33306|https://www.linkedin.com/in/goldavelez/|same_as|0x3176Dd992793ae9C50b92fE09E1bb7CcCdFF8016|my wallet and my linked in
33918|https://live.linkedtrust.us/claims/9924|rated||I spoke to Mohammed several times during this time and am confident he disbursed the money to families and to a school.
33925|https://voiceofachild.org|rated||لقد حضرت تدريب في اللغة الانكليزية و الحاسوب وقد كان ممتع جدا ومفيد
33924|https://voiceofachild.org|related_to||it was great trainings
33095|https://www.linkedin.com/in/goldavelez/|same_as|https://noo.network/user/455d0177-280b-4659-a287-8a36cdb0f7d4|this is me! in both places
118537|https://www.linkedin.com/in/goldavelez/|related_to||Golda Velez is the Co-founder of WhatsCookin.us ( https://www.whatscookin.us/ ) and LinkedTrust (https://live.linkedtrust.us/) and she is very energetic and professional.
33830|https://voiceofachild.org|rated||
33923|https://voiceofachild.org|rated||we have English and computer training
33929|https://live.linkedtrust.us/claims/33830|rated||It was really good trainings .
118499|https://www.amurt.net|impact||In Ebonyi, Nigeria, Amurt ( which is the organization that works in providing help to people) work to provide good health to people of Ebonyi state. The work with hospitals within the state to achieve this. They have been doing since 2010. The help to provide solid health care to baby and mother that have complication in child delivery. They foot the bills and make sure that both the mother and child are healthy as they stay in the hospital. They also cater for care that are extreme and need treatment asap by using their ambulance for quick response. They can also pay for the bills for this too. Sometime they visit hospital to fund people that can pay for their bills so that can be discharged. They have representative of themselves in several hospital and they are across the state of Ebonyi. In summary, they exist to make sure people have a sound health care with small or no cost.
33594|https://VoiceOfAChild.org|impact||Voice of a Child donated $6500 to create a computer learning center in Jarablus, Syria starting with 36 students. These young men and women are learning job skills and have Internet access in a secure location.
33075|https://lifesapitch.io/|rated||And, Ro has continued to be an incredibly valuable collaborator to our team, offering quick insights and help and genuinely sensitive to our needs and position.
33920|https://voiceofachild.org|rated||thank your for your help VOC
118505|https://live.linkedtrust.us/claims/118502|rated||I spoke with Alice and she indicated that she was given a sum of 30 thousand naira to start a groundnut business in 2016, and she is still in the business.
118549|https://live.linkedtrust.us/claims/118541|rated||
33931|https://live.linkedtrust.us/claims/33830|rated||it was great trainings , thank you very much VOC .
118542|https://live.linkedtrust.us/claims/118541|rated||
33922|https://live.linkedtrust.us/claims/33830|agree||
1 change: 0 additions & 1 deletion scripts/fixture_data/edges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@
419553|4762|4764|impact|33594
419554|4764|4012|source|33594
419555|4762|214991|impact|118550
(50 rows)
50 changes: 50 additions & 0 deletions scripts/fixture_data/edges_clean.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
915|648|647|source|9926
917|649|647|source|9927
4548|4017|4012|source|33075
4560|4012|4029|same_as|33095
4561|4012|4029|same_as|33096
5741|4029|4030|same_as|33305
5777|4012|647|same_as|33306
419245|214925|214927|rated|118505
419246|214925|214928|rated|118506
419249|214932|214933|rated|118508
419250|214933|4012|source|118508
419251|214925|214934|rated|118509
419293|4012|214978|related_to|118537
419294|214978|214976|source|118537
419298|214983|214984|rated|118540
419301|214986|214987|rated|118542
419305|214991|214992|impact|118499
419306|214992|214918|source|118499
419307|214992|214921|rated|118500
419308|214992|214922|rated|118501
419309|214918|214925|impact|118502
419310|214925|214889|source|118502
419313|214991|214986|rated|118541
419314|214986|4012|source|118541
419318|4012|214983|related_to|118537
419319|214983|214976|source|118537
419320|214922|214889|source|118501
419321|214992|214995|rated|118546
419323|214992|214998|rated|118548
419324|214986|214999|rated|118549
419502|9767|215148|agree|33919
419508|9767|215153|agree|33922
419509|4762|215154|rated|33923
419510|5021|215155|rated|33835
419511|215155|4012|source|33835
419512|9767|215156|rated|33931
419515|4762|215159|rated|33920
419524|4995|215167|impact|33818
419525|215167|4012|source|33818
419530|9767|215170|rated|33932
419537|4762|215177|rated|33921
419540|4762|215179|related_to|33924
419545|644|215183|rated|33918
419546|215183|4012|source|33918
419547|4762|9767|rated|33830
419548|4762|215184|rated|33925
419551|9767|215186|rated|33929
419553|4762|4764|impact|33594
419554|4764|4012|source|33594
419555|4762|214991|impact|118550
15 changes: 12 additions & 3 deletions scripts/fixture_data/import_fixture.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
BEGIN;
\copy "Node" (id,nodeUri,name,entType,descrip,image,thumbnail) FROM 'nodes.txt' WITH (FORMAT csv, DELIMITER '|');
\copy "Edge" (id,startNodeId,endNodeId,label,thumbnail,claimId) FROM 'edges.txt' WITH (FORMAT csv, DELIMITER '|');
\copy "Claim" (id,subject,claim,object,statement,effectiveDate,sourceURI,howKnown,dateObserved,digestMultibase,author,curator,aspect,score,stars,amt,unit,howMeasured,intendedAudience,respondAt,confidence,issuerId,issuerIdType,claimAddress,proof,createdAt,lastUpdatedAt) FROM 'claims.txt' WITH (FORMAT csv, DELIMITER '|');

ALTER TABLE "Node" ALTER COLUMN descrip DROP NOT NULL;
ALTER TABLE "Edge" DROP CONSTRAINT "Edge_startNodeId_fkey";
ALTER TABLE "Edge" DROP CONSTRAINT "Edge_endNodeId_fkey";
ALTER TABLE "Edge" DROP CONSTRAINT "Edge_claimId_fkey";


\copy "Node" (id,"nodeUri",name,"entType",descrip) FROM '/fixture_data/nodes_clean.txt' WITH (FORMAT csv, DELIMITER '|');
\copy "Edge" (id,"startNodeId","endNodeId",label,"claimId") FROM '/fixture_data/edges_clean.txt' WITH (FORMAT csv, DELIMITER '|');
\copy "Claim" (id,subject,claim,object,statement) FROM '/fixture_data/claims_clean.txt' WITH (FORMAT csv, DELIMITER '|');


COMMIT;
3 changes: 0 additions & 3 deletions scripts/fixture_data/nodes.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
647|0x3176Dd992793ae9C50b92fE09E1bb7CcCdFF8016|0x3176Dd992793ae9C50b92fE09E1bb7CcCdFF8016|ORGANIZATION|
4012|https://www.linkedin.com/in/goldavelez/|https://www.linkedin.com/in/goldavelez/|ORGANIZATION|
4017|https://live.linkedtrust.us/claims/33075|rated|CLAIM|5 out of 5
And, Ro has continued to be an incredibly valuable collaborator to our team, offering quick insights and help and genuinely sensitive to our needs and position.
4029|https://noo.network/user/455d0177-280b-4659-a287-8a36cdb0f7d4|Powered by NooNet|ORGANIZATION|
4762|https://voiceofachild.org|Voice of a Child|ORGANIZATION|
4764|https://live.linkedtrust.us/claims/33594|impact|CLAIM|
Expand Down Expand Up @@ -53,4 +51,3 @@ it was great trainings
I spoke to Mohammed several times during this time and am confident he disbursed the money to families and to a school.
215184|https://live.linkedtrust.us/claims/33925|rated|CLAIM|
لقد حضرت تدريب في اللغة الانكليزية و الحاسوب وقد كان ممتع جدا ومفيد
(28 rows)
Loading

0 comments on commit c961ade

Please sign in to comment.