Skip to content

Commit

Permalink
feat: remove frontend; implement frontend in django
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowtham1729 committed Dec 13, 2023
1 parent d50491e commit 7d64901
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 11,236 deletions.
73 changes: 0 additions & 73 deletions .github/workflows/build-frontend.yml

This file was deleted.

4 changes: 2 additions & 2 deletions applications/backend/django_server/django_server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from . import views

urlpatterns = [
path("api/admin/", admin.site.urls),
path("admin/", admin.site.urls),
path("healthz/", views.healthz, name="healthz"),
path("", include("django_prometheus.urls")), # collect metrics at /metrics
path("api/news/", include("news.urls")),
path("news/", include("news.urls")),
]
27 changes: 27 additions & 0 deletions applications/backend/django_server/news/templates/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="">
<head>
<title>Folio Feed</title>
</head>
<body>
<h1>Folio Feed</h1>

<p>Your Tickers:</p>
<ul>
{% for ticker in tickers %}
<li>{{ ticker }}</li>
{% endfor %}
</ul>

<p>Here is news analysis for {{date}}:</p>
{% for analysis in analysis_items %}
<h2><a href="{% url 'news' analysis.symbol date %}">{{ analysis.symbol }}</a></h2>
<p>Avg Sentiment: {{ analysis.average_sentiment }}</p>
<p>Number of Articles: {{ analysis.total_news }}</p>
<p>Number of Positive Articles: {{ analysis.positive_news }}</p>
<p>Number of Negative Articles: {{ analysis.negative_news }}</p>
<p>Number of Neutral Articles: {{ analysis.neutral_news }}</p>
<p> Need Attention: {{analysis.need_attention}}</p>
{% endfor %}
</body>
</html>
10 changes: 10 additions & 0 deletions applications/backend/django_server/news/templates/news.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1>{{symbol}} on {{date}}</h1>

{% for item in news %}
<h2>{{item.headline}}</h2>
<img src="{{item.img_src_url}}"/>
<p>{{item.summary}} <a href="{{item.src_url}}">{{more}}</a></p>
<p>Sentiment: {{item.sentiment}}</p>
<p>Need Attention: {{item.need_attention}}</p>
<p>Why ? {{item.reason}}</p>
{% endfor %}
4 changes: 3 additions & 1 deletion applications/backend/django_server/news/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@

urlpatterns = [
# path("", views.index, name="main_index"),
path("", include(router.urls)),
path("api/", include(router.urls)),
path("home", views.home, name="home"),
path("news/<str:symbol>/<str:date>", views.news, name="news"),
]
29 changes: 29 additions & 0 deletions applications/backend/django_server/news/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
from django.utils import timezone
from rest_framework import viewsets
from datetime import datetime, timedelta
from django.shortcuts import render

from .models import Analysis, News, Ticker
from .serializers import AnalysisSerializer, NewsSerializer, TickerSerializer


def home(request):
tickers = Ticker.objects.all()
analysis = Analysis.objects.all().filter(date=datetime.now().date() - timedelta(days=1))
return render(
request,
"home.html",
{
'date': datetime.now().date() - timedelta(days=1),
'tickers': tickers,
'analysis_items': analysis,
}
)


def news(request, symbol, date):
date = timezone.datetime.strptime(date, "%Y-%m-%d").date()
news = News.objects.all().filter(symbol=symbol, publish_time__date=date)
return render(
request,
"news.html",
{
'date': date,
'symbol': symbol,
'news': news,
}
)

class NewsViewSet(viewsets.ReadOnlyModelViewSet):
queryset = News.objects.all()
serializer_class = NewsSerializer
Expand Down
6 changes: 0 additions & 6 deletions applications/frontend/.dockerignore

This file was deleted.

24 changes: 0 additions & 24 deletions applications/frontend/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions applications/frontend/Dockerfile

This file was deleted.

75 changes: 0 additions & 75 deletions applications/frontend/README.md

This file was deleted.

37 changes: 0 additions & 37 deletions applications/frontend/app.vue

This file was deleted.

20 changes: 0 additions & 20 deletions applications/frontend/nginx.conf

This file was deleted.

10 changes: 0 additions & 10 deletions applications/frontend/nuxt.config.ts

This file was deleted.

Loading

0 comments on commit 7d64901

Please sign in to comment.