Check account current progress and update database Args: :browser: web driver :username: Account to be updated :logger: library to log actions
(browser, username, logger)
| 2210 | |
| 2211 | |
| 2212 | def save_account_progress(browser, username, logger): |
| 2213 | """ |
| 2214 | Check account current progress and update database |
| 2215 | |
| 2216 | Args: |
| 2217 | :browser: web driver |
| 2218 | :username: Account to be updated |
| 2219 | :logger: library to log actions |
| 2220 | """ |
| 2221 | logger.info("Saving account progress...") |
| 2222 | followers, following = get_relationship_counts(browser, username, logger) |
| 2223 | |
| 2224 | # save profile total posts |
| 2225 | posts = getUserData("graphql.user.edge_owner_to_timeline_media.count", browser) |
| 2226 | |
| 2227 | try: |
| 2228 | # DB instance |
| 2229 | db, id = get_database() |
| 2230 | conn = sqlite3.connect(db) |
| 2231 | with conn: |
| 2232 | conn.row_factory = sqlite3.Row |
| 2233 | cur = conn.cursor() |
| 2234 | sql = ( |
| 2235 | "INSERT INTO accountsProgress (profile_id, followers, " |
| 2236 | "following, total_posts, created, modified) " |
| 2237 | "VALUES (?, ?, ?, ?, strftime('%Y-%m-%d %H:%M:%S'), " |
| 2238 | "strftime('%Y-%m-%d %H:%M:%S'))" |
| 2239 | ) |
| 2240 | cur.execute(sql, (id, followers, following, posts)) |
| 2241 | conn.commit() |
| 2242 | except Exception: |
| 2243 | logger.exception("message") |
| 2244 | |
| 2245 | |
| 2246 | def get_epoch_time_diff(time_stamp, logger): |
no test coverage detected