Skip to content

Commit

Permalink
consider next year as well
Browse files Browse the repository at this point in the history
  • Loading branch information
stefano-ottolenghi committed Dec 11, 2023
1 parent ded8e85 commit 8c226fd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def str2bool(v):
USER = get_ssm_param('com.neo4j.labs.feedback.dbuser')
PASSWORD = get_ssm_param('com.neo4j.labs.feedback.dbpassword')


HOST = 'neo4j+s://27a749ac.databases.neo4j.io'# + get_ssm_param('com.neo4j.labs.feedback.dbhostport')
USER = 'neo4j'#get_ssm_param('com.neo4j.labs.feedback.dbuser')
PASSWORD = 'M5A9dsAdHxLx-Zdoos5GJwq0MvEHFzufbMB2TV5D1MM'

driver = GraphDatabase.driver(HOST, auth=(USER, PASSWORD))


Expand Down Expand Up @@ -123,20 +128,21 @@ def feedback_api(event, context):
now = parser.parse(qs["date"][0])
else:
now = datetime.datetime.now().replace(day=1)
next_month = (now + relativedelta(months=1)).month
next_month = (now + relativedelta(months=1))

params = {
"year": now.year,
"month": now.month,
"next_month": next_month,
"next_year": next_month.year,
"next_month": next_month.month,
"project": project
}

logger.info(f"Retrieving feedback for {params}")

result, _, _ = driver.execute_query("""
MATCH (feedback:Feedback)<-[:HAS_FEEDBACK]-(page:Page)-[:PROJECT]->(:Project {name: $project})
WHERE datetime({year:$year, month:$next_month}) > feedback.timestamp >= datetime({year:$year, month:$month})
WHERE datetime({year:$next_year, month:$next_month}) > feedback.timestamp >= datetime({year:$year, month:$month})
RETURN feedback, page
ORDER BY feedback.timestamp DESC
""", params, database_='neo4j')
Expand Down

0 comments on commit 8c226fd

Please sign in to comment.