Skip to content

Commit 775f60c

Browse files
committed
Improve news and fix stock price realtime/historical views
1 parent 75dbc6e commit 775f60c

File tree

9 files changed

+1624
-59
lines changed

9 files changed

+1624
-59
lines changed

php-symfony-neuron/public/images/news-icon.png

Loading

php-symfony-neuron/public/images/news-icon.svg

Loading

php-symfony-neuron/src/Controller/CompanyController.php

Lines changed: 261 additions & 21 deletions
Large diffs are not rendered by default.

php-symfony-neuron/src/Repository/CompanyRepository.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ public function remove(Company $entity, bool $flush = false): void
4141

4242
/**
4343
* Find companies by name, ticker symbol, industry, or sector
44+
* Uses case-insensitive contains search logic
4445
*/
4546
public function findBySearchCriteria(string $searchTerm, int $limit = 25): array
4647
{
4748
$queryBuilder = $this->createQueryBuilder('c')
48-
->where('c.name LIKE :searchTerm')
49-
->orWhere('c.tickerSymbol LIKE :searchTerm')
50-
->orWhere('c.industry LIKE :searchTerm')
51-
->orWhere('c.sector LIKE :searchTerm')
52-
->setParameter('searchTerm', '%' . $searchTerm . '%')
49+
->where('LOWER(c.name) LIKE LOWER(:searchTerm)')
50+
->orWhere('LOWER(c.tickerSymbol) LIKE LOWER(:searchTerm)')
51+
->orWhere('LOWER(c.industry) LIKE LOWER(:searchTerm)')
52+
->orWhere('LOWER(c.sector) LIKE LOWER(:searchTerm)')
53+
->setParameter('searchTerm', '%' . strtolower($searchTerm) . '%')
5354
->orderBy('c.name', 'ASC')
5455
->setMaxResults($limit);
5556

php-symfony-neuron/src/Service/ApiClient/NewsApiClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public function getCompanyNews(string $query, int $limit = 10, ?\DateTime $from
3636
{
3737
$endpoint = '/everything';
3838
if (!$from) $from = new \DateTime('30 days ago');
39-
if (!$to) $to = new \DateTime();
39+
if (!$to) $to = new \DateTime('tomorrow'); // Use tomorrow to ensure we get today's news
4040
$params = [
4141
'q' => $query,
42-
'searchIn' => 'title',
42+
'searchIn' => 'title,description', // Search in both title and description for better results
4343
'from' => $from->format('Y-m-d'),
4444
'to' => $to->format('Y-m-d'),
4545
'language' => 'en',

php-symfony-neuron/src/Service/StockDataService.php

Lines changed: 306 additions & 27 deletions
Large diffs are not rendered by default.

php-symfony-neuron/templates/base.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
{% include 'base/footer.html.twig' %}
3232

3333
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
34+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script>
3435
{% block javascripts %}{% endblock %}
3536
</body>
3637
</html>

php-symfony-neuron/templates/company/news.html.twig

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
{% block title %}{{ company.name }} - News & Events{% endblock %}
44

5+
{% block javascripts %}
6+
{{ parent() }}
7+
<script>
8+
document.addEventListener('DOMContentLoaded', function() {
9+
// Initialize tooltips
10+
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
11+
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
12+
return new bootstrap.Tooltip(tooltipTriggerEl);
13+
});
14+
});
15+
</script>
16+
{% endblock %}
17+
518
{% block stylesheets %}
619
{{ parent() }}
720
<style>
@@ -88,9 +101,18 @@
88101
<option value="90" {% if days == 90 %}selected{% endif %}>Last 90 days</option>
89102
</select>
90103
</div>
91-
<div class="col-md-4">
104+
<div class="col-md-3">
92105
<button type="submit" class="btn btn-primary w-100">Update</button>
93106
</div>
107+
<div class="col-md-1">
108+
<a href="{{ path('company_news', {'id': company.id, 'limit': limit, 'days': days, 'refresh': true}) }}"
109+
class="btn btn-outline-info w-100"
110+
data-bs-toggle="tooltip"
111+
data-bs-placement="top"
112+
title="Force refresh news cache to get the latest articles">
113+
<i class="fas fa-redo-alt"></i>
114+
</a>
115+
</div>
94116
</form>
95117
</div>
96118
</div>

0 commit comments

Comments
 (0)