Skip to content

Commit

Permalink
Merge pull request #209 from starknet-id/ayush/update-checks
Browse files Browse the repository at this point in the history
feat: add current-time check
  • Loading branch information
Th0rgal authored Apr 26, 2024
2 parents c006acd + 39069d5 commit 26cfbea
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/endpoints/get_quest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub async fn handler(
Query(query): Query<GetQuestsQuery>,
) -> impl IntoResponse {
let collection = state.db.collection::<QuestDocument>("quests");
let current_time = chrono::Utc::now().timestamp_millis();

let pipeline = [
doc! {
Expand All @@ -48,7 +49,7 @@ pub async fn handler(
doc! {
"$lt": [
"$expiry",
"$$NOW"
current_time
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/get_quests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub async fn handler(State(state): State<Arc<AppState>>) -> impl IntoResponse {
doc! {
"$lt": [
"$expiry",
"$$NOW"
current_time
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/get_trending_quests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub async fn handler(
{
"$and": [
{ "$gte": ["$expiry", 0] },
{ "$lt": ["$expiry", "$$NOW"] },
{ "$lt": ["$expiry", current_time] },
]
},
true,
Expand Down
4 changes: 3 additions & 1 deletion src/endpoints/quest_boost/get_quests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub async fn handler(
Query(query): Query<GetQuestForBoostQuery>,
) -> impl IntoResponse {
let boost_id = query.boost_id;
let current_time = chrono::Utc::now().timestamp_millis();

let pipeline = vec![
doc! {
"$match": doc! {
Expand Down Expand Up @@ -87,7 +89,7 @@ pub async fn handler(
{
"$and": [
{ "$gte": ["$$item.expiry", 0] },
{ "$lt": ["$$item.expiry", "$$NOW"] },
{ "$lt": ["$$item.expiry", current_time] },
]
},
true,
Expand Down

0 comments on commit 26cfbea

Please sign in to comment.