Skip to content

Commit d966d8f

Browse files
committed
fixed /subscribe
1 parent 6d88be7 commit d966d8f

File tree

4 files changed

+46
-23
lines changed

4 files changed

+46
-23
lines changed

.github/workflows/ci-cd.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ jobs:
5959
6060
- name: Deploy to AKS
6161
run: |
62-
kubectl set image deployment/my-app-deployment \
62+
kubectl set env deployment/my-app-deployment \
63+
FLASK_ENV=${{ vars.FLASK_ENV }} \
64+
TMPDIR=${{ vars.TMPDIR }} \
65+
DB_TYPE=${{ vars.DB_TYPE }} \
66+
DB_PATH=${{ vars.DB_PATH }} \
67+
SECRET_KEY=${{ secrets.SECRET_KEY }}
68+
HF_HOME=${{ vars.HF_HOME }}
69+
SMTP_USERNAME=${{ secrets.SMTP_USERNAME }}
70+
SMTP_PASSWORD=${{ secrets.SMTP_PASSWORD }}
71+
kubectl set image deployment/onesearchserver \
6372
my-app=${{ secrets.ACR_NAME }}.azurecr.io/${{ vars.DOCKER_IMAGE_NAME }}:${{ github.sha }}
64-
kubectl rollout status deployment/my-app-deployment
73+
kubectl rollout status deployment/onesearchserver

app.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,37 @@ def subscribe():
5050
if not email or not topic or (not techteams and not individuals and not communities):
5151
return jsonify({"status": "error", "message": "Missing email or topic or publisher"
5252
}), 400
53-
conn = app.db.get_connection()
54-
55-
if techteams:
56-
techteams = [team.lower().strip() for team in techteams.split(',')]
53+
try:
54+
conn = app.db.get_connection()
5755

58-
for team in techteams:
59-
publishers = app.db.get_publisher_by_name(conn, team)
60-
if not publishers:
61-
return jsonify({"status": "error", "message": f"Publisher '{team}' not found."
62-
}), 404
63-
64-
publisher = publishers[0]
56+
if techteams:
57+
techteams = [team.lower().strip() for team in techteams.split(',')]
6558

66-
existing_subscriptions = app.db.get_subscriptions_by_email(conn, email)
67-
if not any(sub["publisher"]["id"] == publisher["id"] and sub["topic"] == topic for sub in existing_subscriptions):
68-
app.db.add_subscription(conn, email, topic, publisher['id'])
69-
70-
return jsonify({
71-
"status": "success",
72-
"message": "Subscription updated."
73-
})
59+
for team in techteams:
60+
publishers = app.db.get_publisher_by_name(conn, team)
61+
if not publishers:
62+
return jsonify({"status": "error", "message": f"Publisher '{team}' not found."
63+
}), 404
64+
65+
publisher = publishers[0]
66+
67+
existing_subscriptions = app.db.get_subscriptions_by_email(conn, email)
68+
if not any(sub["publisher"]["id"] == publisher["id"] and sub["topic"] == topic for sub in existing_subscriptions):
69+
app.db.add_subscription(conn, email, topic, publisher['id'])
70+
71+
conn.commit()
72+
return jsonify({
73+
"status": "success",
74+
"message": "Subscription updated."
75+
})
76+
except:
77+
conn.rollback()
78+
return jsonify({
79+
"status": "failed",
80+
"message": "Unable to add Subscription at this time, Could you please try again."
81+
}, 500)
82+
finally:
83+
conn.close()
7484

7585
@app.route("/subscriptions_for_email")
7686
def subscriptions_for_email():
@@ -85,7 +95,7 @@ def subscriptions_for_email():
8595
grouped = {}
8696
for entry in subscriptions:
8797
topic = entry["topic"]
88-
publisher = entry["publisher"]["name"]
98+
publisher = entry["publisher"]["publisher_name"]
8999
if topic not in grouped:
90100
grouped[topic] = set()
91101
grouped[topic].add(publisher)

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ httpcore==1.0.9
2424
httpx==0.28.1
2525
huggingface-hub==0.34.4
2626
idna==3.10
27+
iniconfig==2.1.0
2728
itsdangerous==2.2.0
2829
Jinja2==3.1.6
2930
jiter==0.10.0
@@ -39,14 +40,17 @@ mpmath==1.3.0
3940
namex==0.1.0
4041
networkx==3.5
4142
numpy==2.3.2
43+
openai==1.99.9
4244
opt_einsum==3.4.0
4345
optree==0.17.0
4446
packaging==25.0
4547
pillow==11.3.0
48+
pluggy==1.6.0
4649
protobuf==6.32.0
4750
pydantic==2.11.7
4851
pydantic_core==2.33.2
4952
Pygments==2.19.2
53+
pytest==8.4.1
5054
python-dateutil==2.9.0.post0
5155
PyYAML==6.0.2
5256
regex==2025.7.34

static/script2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ form.addEventListener("submit", function (e) {
6565
companyInput.disabled = true; // show
6666

6767
} else {
68-
alert("Subscription failed.");
68+
alert(result.message);
6969
}
7070
});
7171
});

0 commit comments

Comments
 (0)