Skip to content

Commit 346efd2

Browse files
committed
fix(Project): Description wasn't pulling in, in some cases. Build a workaround.
1 parent 896f529 commit 346efd2

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

app/Console/Commands/IngestData.php

+37-2
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,33 @@ private function validateDate($date)
590590
return $date;
591591
}
592592

593+
/**
594+
* In some cases, a project returns multiple records. Try and find the one with metadata.
595+
*/
596+
private function getProjectDetails($address)
597+
{
598+
$query = '
599+
projects(filter: {id: {equalTo: "' . $address . '"}}) {
600+
id
601+
name
602+
metadata
603+
}
604+
';
605+
606+
$projectData = $this->graphQLQuery($query);
607+
608+
if (count($projectData['projects']) > 0) {
609+
// return the project that has metadata
610+
foreach ($projectData['projects'] as $key => $data) {
611+
if (isset($data['metadata'])) {
612+
return $data;
613+
}
614+
}
615+
}
616+
617+
return null;
618+
}
619+
593620
/**
594621
* Update project data by pulling projects for a specific round
595622
*/
@@ -598,7 +625,7 @@ private function updateProjects($round)
598625
$cacheName = $this->cacheName . 'IngestData::updateProjects(' . $round->id . ')';
599626

600627
$query = '
601-
applications(filter: {roundId: {equalTo: "' . $round->round_addr . '"}}) {
628+
applications(filter: {roundId: {equalTo: "' . $round->round_addr . '"}, chainId: {equalTo: ' . $round->chain->chain_id . '}}) {
602629
id
603630
statusSnapshots
604631
project {
@@ -609,6 +636,7 @@ private function updateProjects($round)
609636
}
610637
}
611638
';
639+
612640
$applicationData = $this->graphQLQuery($query);
613641

614642
$hash = HashService::hashMultidimensionalArray($applicationData);
@@ -624,6 +652,14 @@ private function updateProjects($round)
624652

625653
$metadata = $data['project']['metadata'];
626654

655+
if (!isset($metadata['description'])) {
656+
// If we can't find the metadata, try and make a direct query for the project metadata
657+
$projectData = $this->getProjectDetails($data['project']['id']);
658+
if ($projectData) {
659+
$metadata = $projectData['metadata'];
660+
}
661+
}
662+
627663
$description = null;
628664
if (isset($metadata['description'])) {
629665
$description = $metadata['description'];
@@ -641,7 +677,6 @@ private function updateProjects($round)
641677

642678
$title = isset($data['project']['name']) ? $data['project']['name'] : (isset($metadata['title']) ? $metadata['title'] : null);
643679

644-
645680
$project = Project::updateOrCreate(
646681
['id_addr' => Str::lower($data['project']['id'])],
647682
[

resources/js/Pages/Project/Show.vue

+2-6
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,9 @@ const applications = ref(usePage().props.applications.valueOf());
141141
</a>
142142
</div>
143143
<div
144-
v-if="project.metadata.description"
144+
v-if="project.description"
145145
class="text-xs mt-5 markdown"
146-
v-html="
147-
markdown.render(
148-
project.metadata.description
149-
)
150-
"
146+
v-html="markdown.render(project.description)"
151147
></div>
152148
</div>
153149
</div>

0 commit comments

Comments
 (0)