コード例 #1
0
def compare_db_with_drive(client, conn, limit, offset):
    enrollments = Database.get(Database.execute(conn, Database.enrollment_query_string(limit=limit, offset=offset)))
    database_contents = Database.get(Database.execute(conn, Database.compare_query_string()))

    gd_root_folders = Folder.list_sub_folders(client, "root")
    gd_contents = Folder.list_sub_folders(client, gd_root_folders[config.ROOT_CLASS_FOLDER])

    # REMOVE SYNCED ENROLLMENTS FROM DICT #
    enrollments = [enrollment for enrollment in enrollments if Sync.not_synced(enrollment, database_contents)]
    
    # MOVE ENROLLMENTS THAT NEED TO BE ARCHIVED TO archive_in_drive #
    archive_in_drive = [enrollment for enrollment in enrollments if Sync.should_archive(enrollment, database_contents)]
    enrollments = Utilities.remove_from_list(archive_in_drive, enrollments)

    # MOVE ENROLLMENTS THAT NEED RENAMING TO rename_in_drive #
    rename_course_in_drive = [enrollment for enrollment in enrollments if Sync.course_needs_renaming(conn, enrollment)]
    rename_in_drive = [enrollment for enrollment in enrollments if Sync.student_needs_renaming(enrollment, database_contents)]
    enrollments = Utilities.remove_from_list(rename_in_drive, enrollments)
    
    # MOVE ENROLLMENTS THAT ARE LEFT NEED TO BE CREATED IN DRIVE #
    create_in_drive = enrollments
    rename_course_in_drive = Utilities.remove_from_list(create_in_drive, rename_course_in_drive)

    archive_in_drive = ObjectUtilites.enrollment_list_from_dict(archive_in_drive)
    rename_course_in_drive = ObjectUtilites.enrollment_list_from_dict(rename_course_in_drive)
    rename_in_drive = ObjectUtilites.enrollment_list_from_dict(rename_in_drive)
    create_in_drive = ObjectUtilites.enrollment_list_from_dict(create_in_drive)

    return create_in_drive, rename_course_in_drive, rename_in_drive, archive_in_drive
コード例 #2
0
def set_to_archived(conn, client):
    enrollments = Database.get(Database.execute(conn, Database.enrollment_query_string()))
    database_contents = Database.get(Database.execute(conn, Database.compare_query_string()))

    items_to_archive = {}

    items_to_archive = [entry for entry in database_contents if Sync.not_exists_in_enrollments(entry, enrollments)]

    for entry in items_to_archive:
        Database.set_entry_to_archived(conn, entry)