Skip to content

Instantly share code, notes, and snippets.

@PreedhiVivek
PreedhiVivek / notify_token_expiry.py
Last active March 18, 2024 16:35
A DAG to notify nearing GitHub access token expiry on Skype
"""
DAG to notify nearing GitHub access token expiry on Skype
"""
import logging
from datetime import datetime, timedelta
import requests
from airflow.decorators import dag, task
from airflow.models import Variable
skype_channel = Variable.get("SKYPE_CHANNEL")
@PreedhiVivek
PreedhiVivek / github_lambdas_sequence_dag.py
Created January 11, 2024 05:17
A DAG to run GitHub lambdas on conditional dependency every night
"""
A DAG to run GitHub lambdas on conditional dependency every night
"""
from airflow import DAG
from airflow.decorators import dag, task
from airflow.models import Variable
from datetime import datetime, timedelta
import boto3
import json
import logging
@PreedhiVivek
PreedhiVivek / invoke_lambdas_conditionally.py
Last active March 18, 2024 16:36
Script to invoke GitHub Lambdas conditionally
"""
Script to invoke GitHub Lambdas conditionally
"""
import boto3
import os
import json
import logging
from datetime import datetime
from botocore.exceptions import BotoCoreError, ClientError
from botocore.config import Config
@PreedhiVivek
PreedhiVivek / requirements.txt
Last active March 18, 2024 16:36
Requirements for the insights app
neo4j>=5.3.0
requests>=2.28.1
python-dateutil>=2.8.2
@PreedhiVivek
PreedhiVivek / most_influential_last_week.py
Last active March 18, 2024 16:36
[Insights app] Service to determine the most influential employee for a given duration
"""
Script to fetch the most influential employee from the current week's Survey data
Use-case : Most help given and taken employee (Monday to Friday)
Script to be run at 4pm IST every Friday
"""
from datetime import datetime
import json
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@PreedhiVivek
PreedhiVivek / common_functions.py
Last active March 18, 2024 16:37
[Insights app] Functions common across the Insights app
"""
Script to contain the common functions, used across different microservices, in the Insights app
"""
import os
from datetime import datetime
from dateutil.relativedelta import relativedelta, MO, FR
import requests
from neo4j import GraphDatabase
def initialize_db_driver():
@PreedhiVivek
PreedhiVivek / tech_learnt_most_least._emp.py
Last active March 18, 2024 16:37
[Insights app] Service to report the employee(s) who learnt the most or least the previous month
"""
Script to fetch the employee(s) who learnt the most and least last month, from Survey data.
"""
import json
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import common_functions
def get_tech_query():