From 58f6f7abbc6bcba389d7ac63161f1c078b638bc1 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 30 Aug 2019 09:14:00 +0100 Subject: [PATCH] Dynamically get relevant issues rather than hardcoding the repos This can be applied to PRs in future, too --- Pipfile | 2 + Pipfile.lock | 338 ++++++++++++------ actioner/scheduler/todoist_assigned_issues.py | 79 ++-- actioner/utils/github.py | 15 + .../test_todoist_assigned_issues.py | 9 - 5 files changed, 282 insertions(+), 161 deletions(-) delete mode 100644 tests/test_scheduler/test_todoist_assigned_issues.py diff --git a/Pipfile b/Pipfile index 54a2ea2..b1f167c 100644 --- a/Pipfile +++ b/Pipfile @@ -13,6 +13,7 @@ flake8-mutable = "*" flake8-print = "*" flake8-tuple = "*" black = "*" +ipython = "*" [requires] python_version = "3.7" @@ -32,3 +33,4 @@ pygithub = "*" aiohttp-basicauth = "*" todoist-python = "*" sentry-sdk = "*" +python-dateutil = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 0e66998..93ffd12 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "d6d1208a530bba57b583478e35d644c0d4e881449bb948d334f745b70989a860" + "sha256": "03e80110ad057d53144378ffb7408e120d5196509d80bc31a6092910dd4bd625" }, "pipfile-spec": 6, "requires": { @@ -46,18 +46,19 @@ }, "aiohttp-basicauth": { "hashes": [ - "sha256:277d071c29256e10b4650f1bffee7c2007d914da0c2036e2ab621eb7b2096b2d" + "sha256:02bc53659ed90fcd97fe541e0aa61c1d415ec7304d4757aedb58aa70ca6df358", + "sha256:3f5f05b064c4601bbf24cac42cd55def779aa266cfbd1fe1630ea4a058779003" ], "index": "pypi", - "version": "==0.1.2" + "version": "==0.1.3" }, "apscheduler": { "hashes": [ - "sha256:6599bc78901ee7e9be85cbd073d9cc155c42d2bc867c5cde4d4d1cc339ebfbeb", - "sha256:a8fe0c82d1c21bcf4a1b0e00aa35709f1f63fdd36446e406fa56cc0d51d3acc6" + "sha256:529afb7909e08416132891188cbfea5351eb35e4a684b67e983d819e8d01a6b0", + "sha256:cde18f6dbffa1b75aff67fd7fe423a3020cb0363f6c67bd45f24306d90898231" ], "index": "pypi", - "version": "==3.5.3" + "version": "==3.6.1" }, "async-timeout": { "hashes": [ @@ -68,17 +69,17 @@ }, "attrs": { "hashes": [ - "sha256:10cbf6e27dbce8c30807caf056c8eb50917e0eaafe86347671b57254006c3e69", - "sha256:ca4be454458f9dec299268d472aaa5a11f67a4ff70093396e1ceae9c76cf4bbb" + "sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", + "sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399" ], - "version": "==18.2.0" + "version": "==19.1.0" }, "certifi": { "hashes": [ - "sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7", - "sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033" + "sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939", + "sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695" ], - "version": "==2018.11.29" + "version": "==2019.6.16" }, "chardet": { "hashes": [ @@ -89,10 +90,10 @@ }, "deprecated": { "hashes": [ - "sha256:8bfeba6e630abf42b5d111b68a05f7fe3d6de7004391b3cd614947594f87a4ff", - "sha256:b784e0ca85a8c1e694d77e545c10827bd99772392e79d5f5442e761515a1246e" + "sha256:a515c4cf75061552e0284d123c3066fbbe398952c87333a92b8fc3dd8e4f9cc1", + "sha256:b07b414c8aac88f60c1d837d21def7e83ba711052e03b3cbaff27972567a8f8d" ], - "version": "==1.2.4" + "version": "==1.2.6" }, "idna": { "hashes": [ @@ -137,10 +138,10 @@ }, "pygithub": { "hashes": [ - "sha256:263102b43a83e2943900c1313109db7a00b3b78aeeae2c9137ba694982864872" + "sha256:db415a5aeb5ab1e4a3263b1a091b4f9ffbd85a12a06a0303d5bf083ce7c1b2c8" ], "index": "pypi", - "version": "==1.43.5" + "version": "==1.43.8" }, "pyjwt": { "hashes": [ @@ -149,27 +150,35 @@ ], "version": "==1.7.1" }, + "python-dateutil": { + "hashes": [ + "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", + "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" + ], + "index": "pypi", + "version": "==2.8.0" + }, "pytz": { "hashes": [ - "sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", - "sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c" + "sha256:26c0b32e437e54a18161324a2fca3c4b9846b74a8dccddd843113109e1116b32", + "sha256:c894d57500a4cd2d5c71114aaab77dbab5eabd9022308ce5ac9bb93a60a6f0c7" ], - "version": "==2018.9" + "version": "==2019.2" }, "requests": { "hashes": [ - "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", - "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" + "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", + "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" ], - "version": "==2.21.0" + "version": "==2.22.0" }, "sentry-sdk": { "hashes": [ - "sha256:6f4e264d0ad6267c40e20431a6a50f815515805ffe8eb9815340adf931279523", - "sha256:ded1a85821d555dd68abdc0a8e7e4eee7b096f8a6d7a4821228b52a62a465f07" + "sha256:79e8352b5097aa06014871c6daad0933f59d1fcccc586339464ea86e4877b2ab", + "sha256:aeaaf6ae7cc4030d390e5c95797ac1a2a79ac2c8b687709293975ee808c68784" ], "index": "pypi", - "version": "==0.7.3" + "version": "==0.11.1" }, "six": { "hashes": [ @@ -180,30 +189,30 @@ }, "todoist-python": { "hashes": [ - "sha256:f2d8ee63d0ceabdf548bd0b127e7cd3d9dc42759282033796225c251a2153dcb" + "sha256:69df6f2c659ca341ceb6ff137bf87ba32df8a3b07686d01eeae4c5daa6a26646" ], "index": "pypi", - "version": "==7.0.19" + "version": "==8.0.0" }, "tzlocal": { "hashes": [ - "sha256:27d58a0958dc884d208cdaf45ef5892bf2a57d21d9611f2ac45e51f1973e8cab", - "sha256:f124f198e5d86b3538b140883472beaa82d2c0efc0cd9694dfdbe39079e22e69" + "sha256:11c9f16e0a633b4b60e1eede97d8a46340d042e67b670b290ca526576e039048", + "sha256:949b9dd5ba4be17190a80c0268167d7e6c92c62b30026cf9764caf3e308e5590" ], - "version": "==2.0.0b1" + "version": "==2.0.0" }, "urllib3": { "hashes": [ - "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", - "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" + "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", + "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" ], - "version": "==1.24.1" + "version": "==1.25.3" }, "wrapt": { "hashes": [ - "sha256:4aea003270831cceb8a90ff27c4031da6ead7ec1886023b80ce0dfe0adf61533" + "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1" ], - "version": "==1.11.1" + "version": "==1.11.2" }, "yarl": { "hashes": [ @@ -232,18 +241,25 @@ }, "attrs": { "hashes": [ - "sha256:10cbf6e27dbce8c30807caf056c8eb50917e0eaafe86347671b57254006c3e69", - "sha256:ca4be454458f9dec299268d472aaa5a11f67a4ff70093396e1ceae9c76cf4bbb" + "sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", + "sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399" ], - "version": "==18.2.0" + "version": "==19.1.0" + }, + "backcall": { + "hashes": [ + "sha256:38ecd85be2c1e78f77fd91700c76e14667dc21e2713b63876c0eb901196e01e4", + "sha256:bbbf4b1e5cd2bdb08f915895b51081c041bac22394fdfcfdfbe9f14b77c08bf2" + ], + "version": "==0.1.0" }, "black": { "hashes": [ - "sha256:817243426042db1d36617910df579a54f1afd659adb96fc5032fcf4b36209739", - "sha256:e030a9a28f542debc08acceb273f228ac422798e5215ba2a791a6ddeaaca22a5" + "sha256:09a9dcb7c46ed496a9850b76e4e825d6049ecd38b611f1224857a79bd985a8cf", + "sha256:68950ffd4d9169716bcb8719a56c07a2f4485354fec061cdd5910aa07369731c" ], "index": "pypi", - "version": "==18.9b0" + "version": "==19.3b0" }, "click": { "hashes": [ @@ -254,37 +270,42 @@ }, "coverage": { "hashes": [ - "sha256:029c69deaeeeae1b15bc6c59f0ffa28aa8473721c614a23f2c2976dec245cd12", - "sha256:02abbbebc6e9d5abe13cd28b5e963dedb6ffb51c146c916d17b18f141acd9947", - "sha256:1bbfe5b82a3921d285e999c6d256c1e16b31c554c29da62d326f86c173d30337", - "sha256:210c02f923df33a8d0e461c86fdcbbb17228ff4f6d92609fc06370a98d283c2d", - "sha256:2d0807ba935f540d20b49d5bf1c0237b90ce81e133402feda906e540003f2f7a", - "sha256:35d7a013874a7c927ce997350d314144ffc5465faf787bb4e46e6c4f381ef562", - "sha256:3636f9d0dcb01aed4180ef2e57a4e34bb4cac3ecd203c2a23db8526d86ab2fb4", - "sha256:42f4be770af2455a75e4640f033a82c62f3fb0d7a074123266e143269d7010ef", - "sha256:48440b25ba6cda72d4c638f3a9efa827b5b87b489c96ab5f4ff597d976413156", - "sha256:4dac8dfd1acf6a3ac657475dfdc66c621f291b1b7422a939cc33c13ac5356473", - "sha256:4e8474771c69c2991d5eab65764289a7dd450bbea050bc0ebb42b678d8222b42", - "sha256:551f10ddfeff56a1325e5a34eff304c5892aa981fd810babb98bfee77ee2fb17", - "sha256:5b104982f1809c1577912519eb249f17d9d7e66304ad026666cb60a5ef73309c", - "sha256:5c62aef73dfc87bfcca32cee149a1a7a602bc74bac72223236b0023543511c88", - "sha256:633151f8d1ad9467b9f7e90854a7f46ed8f2919e8bc7d98d737833e8938fc081", - "sha256:772207b9e2d5bf3f9d283b88915723e4e92d9a62c83f44ec92b9bd0cd685541b", - "sha256:7d5e02f647cd727afc2659ec14d4d1cc0508c47e6cfb07aea33d7aa9ca94d288", - "sha256:a9798a4111abb0f94584000ba2a2c74841f2cfe5f9254709756367aabbae0541", - "sha256:b38ea741ab9e35bfa7015c93c93bbd6a1623428f97a67083fc8ebd366238b91f", - "sha256:b6a5478c904236543c0347db8a05fac6fc0bd574c870e7970faa88e1d9890044", - "sha256:c6248bfc1de36a3844685a2e10ba17c18119ba6252547f921062a323fb31bff1", - "sha256:c705ab445936457359b1424ef25ccc0098b0491b26064677c39f1d14a539f056", - "sha256:d95a363d663ceee647291131dbd213af258df24f41350246842481ec3709bd33", - "sha256:e27265eb80cdc5dab55a40ef6f890e04ecc618649ad3da5265f128b141f93f78", - "sha256:ebc276c9cb5d917bd2ae959f84ffc279acafa9c9b50b0fa436ebb70bbe2166ea", - "sha256:f4d229866d030863d0fe3bf297d6d11e6133ca15bbb41ed2534a8b9a3d6bd061", - "sha256:f95675bd88b51474d4fe5165f3266f419ce754ffadfb97f10323931fa9ac95e5", - "sha256:f95bc54fb6d61b9f9ff09c4ae8ff6a3f5edc937cda3ca36fc937302a7c152bf1", - "sha256:fd0f6be53de40683584e5331c341e65a679dbe5ec489a0697cec7c2ef1a48cda" + "sha256:108efa19b676e62590a7a13084098e35183479c0d9608131c20b0921c5a72dc0", + "sha256:16fe3ef881eff27bab287f91dadb4ff0ce4388b9e928d84cbf148a83cc70b3a1", + "sha256:1d0bbc11421827d1100da82ac8dc929532b97ad464038475a0f6505cbf83d6ea", + "sha256:23a8ca5b3c9673f775cc151e85a737f1a967df2ec02b09e8c5a3b606ff2050bf", + "sha256:24b890e51455276762b55cb06fa1c922066e8fc18d1deb1a6399b4d24dfa8ea2", + "sha256:2f0041757ca4801f3c6a74d1660862fdb18a25aea302dd0ce9b067ddbb06b667", + "sha256:3169aba03baddfccdab7cc04cf0878dbf76fc06d300bc35639129a6b794d6484", + "sha256:364fb1bf0f999af2e7f4b1a1e614b2af8c3e0017d11af716aad25f911b7cd0c7", + "sha256:5256856d23f3e45959e7e3a8f9d4cbad3d1613e5660cb8117cd1417798efc395", + "sha256:5b26daa1e1a1147455bf62cd682e504e68f1d1e04235374d50a5248a3c792b1c", + "sha256:60247c8f0c756732e2cfe21f03e6847b923b9a9eaff61f04dc64d3047ec1b669", + "sha256:6463d51507308eb3973340d903537f17ece2ee1e6513aa0c27548fc3a09b0471", + "sha256:64cbadf7a884b299794238bc4391752130e74f71e919993b50c1c431786ef2a2", + "sha256:6de85748ea39ce819ad6d90e660da43964457a1f5cd25262e962a7c7c87945b3", + "sha256:6f95b4794bd84f64aeca25087d8e3abc416aad76842afcac34fa6c3a6f61c62e", + "sha256:778fa184aa3079fa3cbd240e2f5b36771c3382db26bc7bf78aea9d06212c6c66", + "sha256:790a9c5e2dbdf6c41eec9776ed663e99bd36c1604e3bf2e8ae3b123181bfee9f", + "sha256:7d97c1aec0b68b4ea5e3c9edb9fc3f951e8a52360f4bad3aacab9a77defe5b17", + "sha256:93cefddcc0b541d3c52981a232947bf085a38092b0812317f1adb56f02869bcb", + "sha256:95e49867ac616ec63ecd69ea005e65e4b896a48b8db7f9f3ad69f37be29324b7", + "sha256:aca423563eafba66a7c15125391b267befd1e45238de5e1a119ae1fb4ea83b5c", + "sha256:baef7c35e7fce738d9637e9c7a6aa79cb79085e4de49c2ec517ce19239a660f6", + "sha256:c10ccf0797ffce85e93a40aff3a96a3adb63c734f95b59384a7c9522ed25c9e2", + "sha256:ca39704a05bba1886c384a4d7944fda72c53fe5e61979cd933d22084678ad4c1", + "sha256:f6e96d5eee578187f5b7e9266bf646b73de29e2dd7adca8bd83e383680ce1f4c", + "sha256:fc6524511fa664cb4e91401229eedd0dad4ba6ded9c4423fee2f698d78908d9c", + "sha256:fdf2e7e5f074495ad6ea796ca0d245aa6a8b9e4c546ffbf8d30aaaee6601af0f" ], - "version": "==5.0a4" + "version": "==5.0a6" + }, + "decorator": { + "hashes": [ + "sha256:86156361c50488b84a3f148056ea716ca587df2f0de1d34750d35c21312725de", + "sha256:f069f3a01830ca754ba5258fde2278454a0b5b79e0d7f5c13b3b97e57d4acff6" + ], + "version": "==4.4.0" }, "entrypoints": { "hashes": [ @@ -295,19 +316,19 @@ }, "flake8": { "hashes": [ - "sha256:6d8c66a65635d46d54de59b027a1dda40abbe2275b3164b634835ac9c13fd048", - "sha256:6eab21c6e34df2c05416faa40d0c59963008fff29b6f0ccfe8fa28152ab3e383" + "sha256:19241c1cbc971b9962473e4438a2ca19749a7dd002dd1a946eaba171b4114548", + "sha256:8e9dfa3cecb2400b3738a42c54c3043e821682b9c840b0448c0503f781130696" ], "index": "pypi", - "version": "==3.7.6" + "version": "==3.7.8" }, "flake8-comprehensions": { "hashes": [ - "sha256:912a831ff61975b394c3f5444dbc82d033730558574c45373893442f7e7e062d", - "sha256:e93f1053c778893bca368ee779bf5e5a3803fd19e2a32bd272325d010591cd84" + "sha256:7b174ded3d7e73edf587e942458b6c1a7c3456d512d9c435deae367236b9562c", + "sha256:e36fc12bd3833e0b34fe0639b7a817d32c86238987f532078c57eafdc7a8a219" ], "index": "pypi", - "version": "==2.0.0" + "version": "==2.2.0" }, "flake8-mutable": { "hashes": [ @@ -326,19 +347,40 @@ }, "flake8-tuple": { "hashes": [ - "sha256:152f8f750b64e83f8ebd204e02e603028ac30447b19cd9e3b46d344c2c172ca1" + "sha256:8d41db2e4a5320ffd29cf78a95f1d7da9f22b47949427a4d7f8391333eec2a15" ], "index": "pypi", - "version": "==0.2.13" + "version": "==0.4.0" + }, + "ipython": { + "hashes": [ + "sha256:1d3a1692921e932751bc1a1f7bb96dc38671eeefdc66ed33ee4cbc57e92a410e", + "sha256:537cd0176ff6abd06ef3e23f2d0c4c2c8a4d9277b7451544c6cbf56d1c79a83d" + ], + "index": "pypi", + "version": "==7.7.0" + }, + "ipython-genutils": { + "hashes": [ + "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8", + "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8" + ], + "version": "==0.2.0" }, "isort": { "hashes": [ - "sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af", - "sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8", - "sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497" + "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", + "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" ], "index": "pypi", - "version": "==4.3.4" + "version": "==4.3.21" + }, + "jedi": { + "hashes": [ + "sha256:786b6c3d80e2f06fd77162a07fed81b8baa22dde5d62896a790a331d6ac21a27", + "sha256:ba859c74fa3c966a22f2aeebe1b74ee27e2a462f56d3f5f7ca4a59af61bfe42e" + ], + "version": "==0.15.1" }, "mccabe": { "hashes": [ @@ -349,11 +391,20 @@ }, "mypy": { "hashes": [ - "sha256:308c274eb8482fbf16006f549137ddc0d69e5a589465e37b99c4564414363ca7", - "sha256:e80fd6af34614a0e898a57f14296d0dacb584648f0339c2e000ddbf0f4cc2f8d" + "sha256:0107bff4f46a289f0e4081d59b77cef1c48ea43da5a0dbf0005d54748b26df2a", + "sha256:07957f5471b3bb768c61f08690c96d8a09be0912185a27a68700f3ede99184e4", + "sha256:10af62f87b6921eac50271e667cc234162a194e742d8e02fc4ddc121e129a5b0", + "sha256:11fd60d2f69f0cefbe53ce551acf5b1cec1a89e7ce2d47b4e95a84eefb2899ae", + "sha256:15e43d3b1546813669bd1a6ec7e6a11d2888db938e0607f7b5eef6b976671339", + "sha256:352c24ba054a89bb9a35dd064ee95ab9b12903b56c72a8d3863d882e2632dc76", + "sha256:437020a39417e85e22ea8edcb709612903a9924209e10b3ec6d8c9f05b79f498", + "sha256:49925f9da7cee47eebf3420d7c0e00ec662ec6abb2780eb0a16260a7ba25f9c4", + "sha256:6724fcd5777aa6cebfa7e644c526888c9d639bd22edd26b2a8038c674a7c34bd", + "sha256:7a17613f7ea374ab64f39f03257f22b5755335b73251d0d253687a69029701ba", + "sha256:cdc1151ced496ca1496272da7fc356580e95f2682be1d32377c22ddebdf73c91" ], "index": "pypi", - "version": "==0.670" + "version": "==0.720" }, "mypy-extensions": { "hashes": [ @@ -364,10 +415,48 @@ }, "nose2": { "hashes": [ - "sha256:9052f2b46807b63d9bdf68e0768da1f8386368889b50043fd5d0889c470258f3" + "sha256:0ede156fd7974fa40893edeca0b709f402c0ccacd7b81b22e76f73c116d1b999", + "sha256:31d8beb00aed3ccc6efb1742bb90227d883e471715188249f594310676e0ef0e" ], "index": "pypi", - "version": "==0.8.0" + "version": "==0.9.1" + }, + "parso": { + "hashes": [ + "sha256:63854233e1fadb5da97f2744b6b24346d2750b85965e7e399bec1620232797dc", + "sha256:666b0ee4a7a1220f65d367617f2cd3ffddff3e205f3f16a0284df30e774c2a9c" + ], + "version": "==0.5.1" + }, + "pexpect": { + "hashes": [ + "sha256:2094eefdfcf37a1fdbfb9aa090862c1a4878e5c7e0e7e7088bdb511c558e5cd1", + "sha256:9e2c1fd0e6ee3a49b28f95d4b33bc389c89b20af6a1255906e90ff1262ce62eb" + ], + "markers": "sys_platform != 'win32'", + "version": "==4.7.0" + }, + "pickleshare": { + "hashes": [ + "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca", + "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56" + ], + "version": "==0.7.5" + }, + "prompt-toolkit": { + "hashes": [ + "sha256:11adf3389a996a6d45cc277580d0d53e8a5afd281d0c9ec71b28e6f121463780", + "sha256:2519ad1d8038fd5fc8e770362237ad0364d16a7650fb5724af6997ed5515e3c1", + "sha256:977c6583ae813a37dc1c2e1b715892461fcbdaa57f6fc62f33a528c4886c8f55" + ], + "version": "==2.0.9" + }, + "ptyprocess": { + "hashes": [ + "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0", + "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f" + ], + "version": "==0.6.0" }, "pycodestyle": { "hashes": [ @@ -378,10 +467,17 @@ }, "pyflakes": { "hashes": [ - "sha256:5e8c00e30c464c99e0b501dc160b13a14af7f27d4dffb529c556e30a159e231d", - "sha256:f277f9ca3e55de669fba45b7393a1449009cff5a37d1af10ebb76c52765269cd" + "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", + "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" ], - "version": "==2.1.0" + "version": "==2.1.1" + }, + "pygments": { + "hashes": [ + "sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127", + "sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297" + ], + "version": "==2.4.2" }, "six": { "hashes": [ @@ -397,29 +493,47 @@ ], "version": "==0.10.0" }, + "traitlets": { + "hashes": [ + "sha256:9c4bd2d267b7153df9152698efb1050a5d84982d3384a37b2c1f7723ba3e7835", + "sha256:c6cb5e6f57c5a9bdaa40fa71ce7b4af30298fbab9ece9815b5d995ab6217c7d9" + ], + "version": "==4.3.2" + }, "typed-ast": { "hashes": [ - "sha256:035a54ede6ce1380599b2ce57844c6554666522e376bd111eb940fbc7c3dad23", - "sha256:037c35f2741ce3a9ac0d55abfcd119133cbd821fffa4461397718287092d9d15", - "sha256:049feae7e9f180b64efacbdc36b3af64a00393a47be22fa9cb6794e68d4e73d3", - "sha256:19228f7940beafc1ba21a6e8e070e0b0bfd1457902a3a81709762b8b9039b88d", - "sha256:2ea681e91e3550a30c2265d2916f40a5f5d89b59469a20f3bad7d07adee0f7a6", - "sha256:3a6b0a78af298d82323660df5497bcea0f0a4a25a0b003afd0ce5af049bd1f60", - "sha256:5385da8f3b801014504df0852bf83524599df890387a3c2b17b7caa3d78b1773", - "sha256:606d8afa07eef77280c2bf84335e24390055b478392e1975f96286d99d0cb424", - "sha256:69245b5b23bbf7fb242c9f8f08493e9ecd7711f063259aefffaeb90595d62287", - "sha256:6f6d839ab09830d59b7fa8fb6917023d8cb5498ee1f1dbd82d37db78eb76bc99", - "sha256:730888475f5ac0e37c1de4bd05eeb799fdb742697867f524dc8a4cd74bcecc23", - "sha256:9819b5162ffc121b9e334923c685b0d0826154e41dfe70b2ede2ce29034c71d8", - "sha256:9e60ef9426efab601dd9aa120e4ff560f4461cf8442e9c0a2b92548d52800699", - "sha256:af5fbdde0690c7da68e841d7fc2632345d570768ea7406a9434446d7b33b0ee1", - "sha256:b64efdbdf3bbb1377562c179f167f3bf301251411eb5ac77dec6b7d32bcda463", - "sha256:bac5f444c118aeb456fac1b0b5d14c6a71ea2a42069b09c176f75e9bd4c186f6", - "sha256:bda9068aafb73859491e13b99b682bd299c1b5fd50644d697533775828a28ee0", - "sha256:d659517ca116e6750101a1326107d3479028c5191f0ecee3c7203c50f5b915b0", - "sha256:eddd3fb1f3e0f82e5915a899285a39ee34ce18fd25d89582bc89fc9fb16cd2c6" + "sha256:18511a0b3e7922276346bcb47e2ef9f38fb90fd31cb9223eed42c85d1312344e", + "sha256:262c247a82d005e43b5b7f69aff746370538e176131c32dda9cb0f324d27141e", + "sha256:2b907eb046d049bcd9892e3076c7a6456c93a25bebfe554e931620c90e6a25b0", + "sha256:354c16e5babd09f5cb0ee000d54cfa38401d8b8891eefa878ac772f827181a3c", + "sha256:4e0b70c6fc4d010f8107726af5fd37921b666f5b31d9331f0bd24ad9a088e631", + "sha256:630968c5cdee51a11c05a30453f8cd65e0cc1d2ad0d9192819df9978984529f4", + "sha256:66480f95b8167c9c5c5c87f32cf437d585937970f3fc24386f313a4c97b44e34", + "sha256:71211d26ffd12d63a83e079ff258ac9d56a1376a25bc80b1cdcdf601b855b90b", + "sha256:95bd11af7eafc16e829af2d3df510cecfd4387f6453355188342c3e79a2ec87a", + "sha256:bc6c7d3fa1325a0c6613512a093bc2a2a15aeec350451cbdf9e1d4bffe3e3233", + "sha256:cc34a6f5b426748a507dd5d1de4c1978f2eb5626d51326e43280941206c209e1", + "sha256:d755f03c1e4a51e9b24d899561fec4ccaf51f210d52abdf8c07ee2849b212a36", + "sha256:d7c45933b1bdfaf9f36c579671fec15d25b06c8398f113dab64c18ed1adda01d", + "sha256:d896919306dd0aa22d0132f62a1b78d11aaf4c9fc5b3410d3c666b818191630a", + "sha256:ffde2fbfad571af120fcbfbbc61c72469e72f550d676c3342492a9dfdefb8f12" ], - "version": "==1.3.1" + "version": "==1.4.0" + }, + "typing-extensions": { + "hashes": [ + "sha256:2ed632b30bb54fc3941c382decfd0ee4148f5c591651c9272473fea2c6397d95", + "sha256:b1edbbf0652660e32ae780ac9433f4231e7339c7f9a8057d0f042fcbcea49b87", + "sha256:d8179012ec2c620d3791ca6fe2bf7979d979acdbef1fca0bc56b37411db682ed" + ], + "version": "==3.7.4" + }, + "wcwidth": { + "hashes": [ + "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", + "sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c" + ], + "version": "==0.1.7" } } } diff --git a/actioner/scheduler/todoist_assigned_issues.py b/actioner/scheduler/todoist_assigned_issues.py index 7b73c6e..1cf4dfa 100644 --- a/actioner/scheduler/todoist_assigned_issues.py +++ b/actioner/scheduler/todoist_assigned_issues.py @@ -4,11 +4,9 @@ from github import Issue from actioner.clients import get_todoist_client, github from actioner.utils import get_todoist_project_from_repo -from actioner.utils.github import get_existing_task, get_issue_link +from actioner.utils.github import get_existing_task, get_issue_link, get_relevant_issues from actioner.utils.todoist import is_task_completed -REPOS = ["srobo/tasks", "srobo/competition-team-minutes"] - LABEL_TO_STATUS = {"must have": 4, "critical": 4, "should have": 2} logger = logging.getLogger(__name__) @@ -23,54 +21,55 @@ def issue_to_task_name(issue: Issue) -> str: return get_issue_link(issue) + ": " + issue.title +def get_existing_tasks(project_id, todoist): + return { + item["id"]: item["content"] + for item in todoist.state["items"] + if item["project_id"] == project_id + } + + def todoist_assigned_issues(): todoist = get_todoist_client() me = github.get_user() todoist.projects.sync() todoist.items.sync() - for repo_name in REPOS: - project_id = get_todoist_project_from_repo(repo_name) - existing_tasks = { - item["id"]: item["content"] - for item in todoist.state["items"] - if item["project_id"] == project_id - } - repo = github.get_repo(repo_name) - for issue in repo.get_issues(assignee=me.login, state="all"): - me_assigned = me.login in {assignee.login for assignee in issue.assignees} - existing_task_id = get_existing_task(existing_tasks, issue) + for issue in get_relevant_issues(): + project_id = get_todoist_project_from_repo(issue.repository.full_name) + existing_tasks = get_existing_tasks(project_id, todoist) + me_assigned = me.login in {assignee.login for assignee in issue.assignees} + existing_task_id = get_existing_task(existing_tasks, issue) - if existing_task_id and not me_assigned: - logger.info("Deleting task for '{}'".format(issue.title)) - todoist.items.delete([existing_task_id]) + if existing_task_id and not me_assigned: + logger.info("Deleting task for '{}'".format(issue.title)) + todoist.items.delete([existing_task_id]) - elif ( - issue.state == "closed" - and existing_task_id is not None - and not is_task_completed(todoist.items.get_by_id(existing_task_id)) - ): - logger.info("Completing task for '{}'".format(issue.title)) - todoist.items.complete([existing_task_id]) + elif ( + issue.state == "closed" + and existing_task_id is not None + and not is_task_completed(todoist.items.get_by_id(existing_task_id)) + ): + logger.info("Completing task for '{}'".format(issue.title)) + todoist.items.complete([existing_task_id]) - elif issue.state == "open": - if existing_task_id is None: - logger.info("Creating task for '{}'".format(issue.title)) - existing_task_id = todoist.items.add( - issue_to_task_name(issue), project_id - )["id"] - existing_task = todoist.items.get_by_id(existing_task_id) + elif issue.state == "open": + if existing_task_id is None: + logger.info("Creating task for '{}'".format(issue.title)) + existing_task_id = todoist.items.add( + issue_to_task_name(issue), project_id=project_id + )["id"] + existing_task = todoist.items.get_by_id(existing_task_id) - if is_task_completed(existing_task): - logger.info("Re-opening task '{}'".format(issue.title)) - todoist.items.uncomplete([existing_task_id]) + if is_task_completed(existing_task): + logger.info("Re-opening task '{}'".format(issue.title)) + todoist.items.uncomplete([existing_task_id]) + existing_task.update( + content=issue_to_task_name(issue), priority=get_status_for_issue(issue) + ) + if issue.milestone and issue.milestone.due_on: existing_task.update( - content=issue_to_task_name(issue), - priority=get_status_for_issue(issue), + date_string=issue.milestone.due_on.strftime("%d/%m/%Y") ) - if issue.milestone and issue.milestone.due_on: - existing_task.update( - date_string=issue.milestone.due_on.strftime("%d/%m/%Y") - ) todoist.commit() diff --git a/actioner/utils/github.py b/actioner/utils/github.py index 19d23fa..36b7f21 100644 --- a/actioner/utils/github.py +++ b/actioner/utils/github.py @@ -1,5 +1,10 @@ +import datetime from typing import Dict +from dateutil.relativedelta import relativedelta + +from actioner.clients import github + def get_issue_link(issue_or_pr) -> str: return "[#{id}]({url})".format(id=issue_or_pr.number, url=issue_or_pr.html_url) @@ -11,3 +16,13 @@ def get_existing_task(tasks: Dict[int, str], issue_or_pr): if issue_link in task_title: return task_id return None + + +def get_relevant_issues(): + since = datetime.datetime.now() - relativedelta(weeks=1) + for repo in github.get_user().get_repos(): + if repo.updated_at < since: + continue + for issue in repo.get_issues(since=since, state="all"): + if issue.pull_request is None: + yield issue diff --git a/tests/test_scheduler/test_todoist_assigned_issues.py b/tests/test_scheduler/test_todoist_assigned_issues.py deleted file mode 100644 index 94635c9..0000000 --- a/tests/test_scheduler/test_todoist_assigned_issues.py +++ /dev/null @@ -1,9 +0,0 @@ -from actioner.scheduler.todoist_assigned_issues import REPOS -from actioner.utils import get_todoist_project_from_repo -from tests import BaseTestCase - - -class ConfigurationTestCase(BaseTestCase): - def test_repo_is_known(self): - for repo in REPOS: - self.assertIsNotNone(get_todoist_project_from_repo(repo))